4 ms·
I wish SQL did not require a comma between items after the SELECT and before the FROM. We don't need commas in between joins. I feel like someone could write a
by BitwiseFool 4y ago
I wish SQL did not require a comma between items after the SELECT and before the FROM. We don't need commas in between joins. I feel like someone could write a way to parse queries so that it isn't needed.
Can you imagine how much time and effort that would save people?
Edit: You do need commas in ORDER BYs, that slipped my mind when typing out this pet peeve of mine.
- irrational 4y agoBut, what would the token be? Where clauses are separated by AND and OR. Order by are separated by commas. Joins are separated by JOIN, INNER JOIN, AND, etc. The parser knows where the WHERE clauses are because they see the WHERE token.
- jemmyw 4y agoI'd be happy if it just accepted a dangling comma so you can swap your columns around freely without causing a syntax error
- cfeduke 4y agoWhen you see queries written like: select 1 ,field1 ,field2 ,field3 from ... you've hit peak SQL engineer comma frustration workaround.
- evanelias 4y agoThat wouldn't be possible to parse, because of how column aliasing works: the "AS" keyword is optional. In other words, "SELECT foo something_else" is equivalent to "SELECT foo AS something_else". Also, I seem to recall that very old versions of Oracle did require commas between joins. (The join conditions had to be stated in the WHERE clause back then, instead of supporting the ON clause, iirc).
- marcosdumay 4y agoYou can use commas between tables perfectly well. The `join` token just has the same role as the comma, making it redundant.
- dragonwriter 4y ago> I wish SQL did not require a comma between items after the SELECT and before the FROM. > Can you imagine how much time and effort that would save people? I can imagine how much extra time I’d spend typing “AS” in queries, which would ne necessary for column aliases to be distinct from new select items. And how much more time I’d spend reading unreadable queries in contexts like logs where they aren’t pretty-printed. Net, it seems to be a big loss. > We don’t need commas in between joins. That’s because each join is introduced by a string of one or more reserved words (including JOIN). If each select field was prefaces with FIELD you wouldn’t need commas, but...