Smart alignment -- ON plus AND/OR

3 Posts
2 Users
0 Reactions
63 Views
(@hwmonkey)
Member
Joined: 2 months ago
Posts: 2
Topic starter  

The join is arguably the most important part of SQL, and when one of our coders gets it wrong, the most troublesome. We implemented a formatting standard to expedite clarity of reading the joins for the really complex ones, that involve AND or OR. It really is just aligning the AND/OR keywords with the ON. Code would look something like:

 SELECT
     na.*
   , zian.abbr
   , net.field2
 FROM note_actions na
   INNER JOIN myschema.tbl_edit_trail  net  ON na.note_id  = net.note_id
   INNER JOIN myschema.tbl_emp         emp  ON emp.user_id = net.user_id
                                           AND emp.prac_id = na.prac_id
   INNER JOIN myschema.tbl_nose       zian  ON net.nose_c  = zian.note_c
                                            OR na.nose_c   = zian.note_c
 WHERE
     zian.abbr = 'CON'

Currently, I cannot figure out how to do this with SQLinForm


   
Quote
Guido
(@admin)
Member Admin
Joined: 3 years ago
Posts: 216
 

Hi @hwmonkey,

when a linebreak is inserted beforte AND/OR in a JOIN statement it starts at the left margin or at (left margin + one indent level). Its position is not based upon the position of the ON. But this sounds like a good idea for a future  release

grafik

Regards

Guido


   
ReplyQuote
(@hwmonkey)
Member
Joined: 2 months ago
Posts: 2
Topic starter  

Thanks @admin,

Thank you for the recommended settings. Thank you for considering this feature in a future release. Once a person gets used to it being formatted like this, it is remarkably easy to quickly debug/understand.


   
ReplyQuote
Share: