4 ms·
> I find that I like English "sentence case" for it, I could go either way, but if you want to go back and modify a query, this makes it more difficult for m
by akira2501 2y ago
> I find that I like English "sentence case" for it,
I could go either way, but if you want to go back and modify a query, this makes it more difficult for me. I just use a block syntax for my queries:
SELECT *
FROM the_table
WHERE some_column = 12
AND other_column IS NOT NULL
ORDER BY order_column;
- cwbriscoe 2y agoSELECT * FROM the_table WHERE some_column = 12 AND other_column IS NOT NULL ORDER BY order_column; I usually don't bother with ALL-CAP keywords.
- wruza 2y agoI use a similar structure but without column alignment. SELECT a, b FROM t1 JOIN t2 ON … WHERE cond1 AND cond2 ORDER/GROUP/HAVING etc
- justanorherhack 2y agoThis is the way, everyone else is wrong.
- WorldMaker 2y agoIt's a bit of a "Why not both?" situation, I think? You can have blocks and sentence case: Select * from the_table where some_column = 12 and other_column is not null order by order_column; That seems so much more readable to me. As I said, that single capital `S` in the outermost "select" has come in surprisingly handy in my experience when scanning through a collection of statements or a transaction or a stored procedure or even just a statement with a bunch of nested sub-selects. It's an interesting advantage I find over "all lower case" or "all upper case" keywords.
- 4ggr0 2y agoyour example is less readable for me. not by a lot, but still. the other example has the commands, in caps, on the left and the values on the right, in lowercase. your example removes one of those aspects and makes everything lowercase. my brain can ignore all-caps stuff, as these are just commands and the things i actually care about mostly are the values. but i mean, in the end, it's just preferences. if you write SQL-queries, #1 is that you understand them well :)
- Ntrails 2y ago> your example is less readable for me. not by a lot, but still Agree, but I wonder how much of that is just the lack of colouring. My brain is suuuuper hard wired to expect all the special keywords to be identified that way as well as by case. Mostly I'm a caps guy because my ahk scripts expand text like "ssf","w" and "gb"* to be the way I learned to write them at first.