I am working on my SQL, and I have the following statement:
1 SELECT c.credit_display, t.title, t.provider
2 FROM credits c
3 INNER JOIN title t
4 ON c.vendor_id = t.vendor_id
5 WHERE c.position = 'Director' and t.provider = 'Premiere'
6 INTO OUTFILE '/var/tmp/file.csv'
7 FIELDS TERMINATED BY ','
I was wondering what the correct formatting would be with regards to tabs. What is the suggested practice for when to indent (for example, should the third line be two tabs or three?).
This is all highly subjective.
Since the
INTO OUTFILEandFIELDSoptions belong to the entireSELECTstatement, I probably wouldn’t indent them beneath theWHEREclause, but rather at the leftmost position (no indentation)Since you have multiple
WHEREconditions, you may indent each on a new line. I would apply the same toSELECTcolumns andFROMtables. TheONclause in theJOINis indented beneath theJOINed table it applies to.Indentation is a very subjective matter, and the best thing to do is come to agreement with your team on how you are all indenting code.