Better HN
topnewbestaskshowjobs
Log inSign up

jgilfillan

1 karma · joined Nov 3, 2016 (10y ago) · 1 submissions

Submissions

comment 10y ago · link · parent

This is how I write SQL:

  select
     col1
    ,col2
    ,col3
  from table1 a
  
  left join table 2 b
    on a.col1 = b.col2
  
  where 1=1
    and col1 = 'condition'
    and col2 = 'condition2'
  ;


 * everything lower case (except strings)
 * leading commas
 * conditions indented by two spaces
 * select columns indented by two spaces, except the first colunm which is indented by three.
 * where 1=1 for easier commenting/uncommenting of conditions