Re:Writing more legible SQL
by 83457 on Thursday November 03, 2016 @04:41AM
(#12862406)
I think of joins as operators and from as the block similar to and/or in the where clause. He is being inconsistent with line breaks for select, from and where blocks. Personally I want to be able to visually pick out the blocks of the query and the easiest way to do that is with indention imo.
[ Parent
| on HN ]
If "joins" are operators like "and", and you put "and" at the end of the line, shouldn't you put "join" at the end too?
from
table1 t1 join
table2 t2 on t1.col2 = t2.col1 join
table3 t3 on
t1.col3 = t3.col1 and
t3.col2 = something_elsewell I don't put and/or at the end of lines so there is that... but I have seen people but joins at the end of lines