3 ms·
I'm not a big fan of this style. It's technically 'organized' (in the sense that there's a definite consistency), but it's vertical to the point of reduced rea
by jmduke 14y ago
I'm not a big fan of this style. It's technically 'organized' (in the sense that there's a definite consistency), but it's vertical to the point of reduced readability: trivial queries can take up dozens of lines.
- kbenson 14y ago> trivial queries can take up dozens of lines. My general rule-of-thumb is that trivial things can have syntax constraints relaxed, as long as it makes them more readable, not less. I may adopt the style of the article for a complex query, but for something simpler I may go with: SELECT foo, bar, baz FROM my_table WHERE foo=1 AND bar > 10 GROUP BY bar ORDER BY baz But that becomes less readable after more than a couple fields or conditions for each line. Until that point, I think it's fairly concise and efficient. That said, if your SQL is intermixed with code whose sole purpose isn't to deal with that SQL, you are probably in for hurt later on anyway. If it is safely quarantined into data access routines of some sort, the size doesn't really matter, since the function or method containing the query should really be about that query.