3 ms·
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 i
by eric_the_read 8y 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)
- overcast 8y agoI do similar, keeps both keywords and fields vertically aligned.
- jerrysievert 8y agoI do too, but it breaks down on me for some specific: * ORDER BY * INNER JOIN etc
- FelipeCortez 8y agosql-indent for Emacs supports that: https://github.com/alex-hhh/emacs-sql-indent https://github.com/alex-hhh/emacs-sql-indent
- zeroimpl 8y agoI 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 8y agoI’ve adopted the same format myself, it reminds me of aligning numbers at the decimal point.
- mjibson 8y agosqlfmt gets pretty close to this: https://sqlfum.pt/?n=30&indent=4&spaces=1&simplify=1&align=2&sql=ICBTRUxFQ1QgZmllbGQsIG90aGVyX2ZpZWxkCiAgICBGUk9NIHRibAogICBXSEVSRSBzb21lX3RoaW5nIElOICgKICAgICAgICAgU0VMRUNUIGlkIAogICAgICAgICAgIEZST00gb3RoZXJfdGFibGUKICAgICAgICAgKQogICAgIEFORCBvdGhlcl9maWVsZCBJUyBOT1QgTlVMTA%3D%3D https://sqlfum.pt/?n=30&indent=4&spaces=1&simplify=1&align=2...