News for hackers. Stuff that matters.
Re:Shouldn't FROM come before SELECT in SQL? (2011) by willvarfar on Thursday January 25, 2024 @11:39AM (#39131460)
An SQL parser has no problem supporting both forms as there is no parsing ambiguity.

(SQL is full of corner cases e.g. EXTRACT(WEEKDAY FROM field) etc. Putting the FROM first, or supporting multiple chained WHERE clauses or allowing WHERE before JOIN and applying to the preceding projection etc is all possible in an SQL parser that chooses to allow some relaxations. Personally, I am really irritated that I can't have HAVING without GROUP or QUALIFY without window functions etc, as I often construct queries programmatically.)

Re:Shouldn't FROM come before SELECT in SQL? (2011) by deepsun on Thursday January 25, 2024 @12:07PM (#39131855)
Nitpick -- SQL was not designed to be used programmatically. Same as shell commands, it's for humans to write manually. Proper API could have way more concise, and much more efficient format to parse. And would avoid a bunch of security issues along the way, same as for shell.
Re:Shouldn't FROM come before SELECT in SQL? (2011) by rangerelf on Thursday January 25, 2024 @01:06PM (#39132491)
Exactly. I still remember about this "revolutionary" querying language being designed, that would allow for non-technical people to perform complex queries and reports from databases.

People: stop trying to mangle SQL "because it would be better..."; nah, SQL is supposed to be the "better" already. The idiosyncrasies it has is because it was designed to be kinda-sorta conversational, modeled as an english language query.

Re:Shouldn't FROM come before SELECT in SQL? (2011) by randomdata on Thursday January 25, 2024 @02:41PM (#39134148)
> SQL is supposed to be the "better" already.

For non-technical people. It is not supposed to be the "better" for the technical people who end up using SQL in practice. QUEL was the "better" for us, being much closer to Codd's vision. But, alas, Oracle won with the business people and Postgres lost.

Re:Shouldn't FROM come before SELECT in SQL? (2011) by The_Colonel on Thursday January 25, 2024 @01:17PM (#39132643)
This specific issue is a problem for humans, not for APIs.

I have a very smart SQL IDE with great intellisense, but when I type "SELECT", it can't help me because it has no idea what I want. Being able to type "FROM table SELECT" would be way friendlier for humans, because IDEs could offer me immediately columns I'm very likely interested in.

Re:Shouldn't FROM come before SELECT in SQL? (2011) by randomdata on Thursday January 25, 2024 @03:04PM (#39134439)
Why is a very smart SQL IDE not able to work around that limitation with smart UI/UX? I can see why baby's first SQL IDE would benefit from the language being amenable to IDEs, but a very smart one should be able to take things further, no?
Re:Shouldn't FROM come before SELECT in SQL? (2011) by mrguyorama on Thursday January 25, 2024 @04:29PM (#39135588)
Alright, I start typing out "SELECT" in my super smart IDE, how does it know which table to suggest columns from?
Re:Shouldn't FROM come before SELECT in SQL? (2011) by randomdata on Thursday January 25, 2024 @04:50PM (#39135867)
Given that it is a very smart IDE, the column suggestion UI integrates table selection in a smart way. Once the IDE knows which table(s) you are referencing, it automatically fills in the FROM clause for you.
Re:Shouldn't FROM come before SELECT in SQL? (2011) by The_Colonel on Friday January 26, 2024 @04:00PM (#39148256)
Looks like my IDE isn't that smart. So I will have to endure the unfriendliness of the SQL towards humans.
Re:Shouldn't FROM come before SELECT in SQL? (2011) by randomdata on Friday January 26, 2024 @05:08PM (#39149294)
Or just use a better language. SQL was designed for non-technical people, using statements that resemble the English they already know. It was not designed for tech-minded people who are able to grasp higher level technical concepts.
Re:Shouldn't FROM come before SELECT in SQL? (2011) by deepsun on Friday January 26, 2024 @02:43AM (#39139844)
I usually write "SELECT FROM a" and then "Ctrl-Left-Left" to go back to columns. Starting from FROM would be better of course.