Comment by thiht
1 year ago
Honestly SQL screwed things up from the very beginning. "SELECT FROM" makes no sense at all. The projection being before the selection is dumb as hell. This is why we can’t get proper tooling for writing SQL, even autocompletion can’t work sanely. You write "SELECT", what’s it gonna autocomplete?
PRQL gives me hope that we might finally get something nice some day
The initial version of SQL was called "Structured English Query Language".
If the designers intended to create a query language that resembled an English sentence, it makes sense why they chose "SELECT FROM".
"Select the jar from the shelf" vs. "From the shelf, select the jar".
“Go to the shelf and select the jar”. You’re describing a process, so it’s natural to formulate it in chronological order.
SQL is a declarative language not a procedural one. You tell the query planner what you want, not how to do it.
FROM clauses aren't required, and using multiple tables in FROM doesn't seem to work out too well when that syntax is listed first.
Doesn’t change anything, you can still have the select at the end, and optional from and joins at the beginning. In your example, the select could be at the end, it’s just that there’s nothing before.
Beginning with Oracle Database Release 23 [released May 2, 2024], it is now optional to select expressions using the FROM DUAL clause.
WITH clauses are optional and appear before SELECT. No reason why the FROM clause couldn't behave the same
Isn't that strictly for CTEs? In which case, you are SELECTing from the CTE.
I also hate having SELECT before FROM because I want to think of the query as a transformation that can be read from top to bottom to understand the flow.
But I assume that that’s part of why they didn’t set it up that way — it’s just a little thing to make the query feel more declarative and less imperative
> what’s it gonna autocomplete?
otoh if you selected something the from clause and potentially some joins could autocomplete
Not reliably, especially if you alias tables. Realistically, you need to know what you’re selecting from before knowing what you’re selecting.