Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Why does SQL require commas between select items and not joins?
1 point by BitwiseFool on Aug 13, 2021 | hide | past | favorite | 3 comments
Why is it that the columns after the SELECT and before the FROM require comma delineation when the JOINS and conditions in the WHERE clause do not? It seems like you could write an implementation of SQL that can manage without commas, what's stopping someone from doing this?

Or, is there some flavor of SQL that eliminates the need for comma delineation already?




Older style SQL did have commas between the tables in the from field. You would then use the different join types in the where condition (= *= =*). As for the where condition not having it think of the where condition as one giant boolean logic thing so commas probably would not make sense there.

As for the select I would assume you need some sort of 'this is not an alias'. But if I remember correctly you at one point you did not need the 'as' condition for the column if you wanted to do aliases for some SQL dialects. Someone can correct me if I have that wrong...

So many programs had to handle older and newer syntax at the same time. There was no reason really change select statement much. So if you could have alias but no 'as' condition the thing would not be able to tell where the new column is and would probably get horribly confused if you didnt have a delimiter which they picked as a comma.

Not sure if there are any dialects that do not have the comma. That dialect would be probably considered 'out of spec'.


The joins and conditions have their own delimiters, just like the comma between the columns: For joins, the word "join"; for conditions, "and" or "or".


in postgres you can do

SELECT a.this, b.that FROM a, b WHERE a.id = b.a_id;

it just implies SELECT ... FROM a LEFT JOIN b ON(true) WHERE ...




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: