top | item 18188181

(no title)

eric_the_read | 7 years ago

I'll have to see if I can adapt this to my somewhat idiosyncratic syntax:

  SELECT field, other_field
    FROM table
   WHERE some_thing IN (
         SELECT id 
           FROM other_table
         )
     AND other_field IS NOT NULL
(mostly it's right-aligning keywords, but there are a few other weird tweaks)

discuss

order

zeroimpl|7 years ago

I tried your SQL in the demo, and it came out like this:

    SELECT
        field,
        other_field
    FROM
        TABLE
    WHERE
        some_thing IN (
            SELECT
                id
            FROM
                other_table)
            AND other_field IS NOT NULL
I'd have expected the last line to have one less indentation level...

ComputerGuru|7 years ago

I’ve adopted the same format myself, it reminds me of aligning numbers at the decimal point.

overcast|7 years ago

I do similar, keeps both keywords and fields vertically aligned.

jerrysievert|7 years ago

I do too, but it breaks down on me for some specific:

* ORDER BY

* INNER JOIN

etc