Earlier quoted context omitted.
"Select green apples from the refrigerator" vs "from the refrigerator, select green apples" The first is much more naturally spoken.
In English. I think other languages would have different word orderings. German for one, and I think maybe Russian too.
Shouldn't FROM come before SELECT in SQL? (2011)
131–137 of 137 posts
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#132Earlier quoted context omitted.
I wonder if there is a concept of infinite length SQL tables. Not sure what would happen with: ORDER DESC COUNT(*) I can't find anything after a quick search except recursive views that must terminate (therefore aren't infinite)
COUNT is easy: > SELECT COUNT(*) FROM ℤ; ℵ₀ > SELECT COUNT(*) FROM ℝ; POWER(2,ℵ₀) > EXEC sp_configure 'continuum hypothesis','1'; > RECONFIGURE; > SELECT COUNT(*) FROM ℝ; ℵ₁ While non-termination is probably best left implementation-defined (to allow caller-terminated streams of infinite results where they make sense), ORDER BY would clearly be an error where no well-defined "first" or "next" result exists.
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#133My mental model was always that the order of keywords mirrored the order the database engine applied them. So WHERE is processed first and SELECT last.
It’s not really mirrored (assuming you meant reversed). Here’s a page describing the two orders in relation to each other from a wiki I wrote: https://github.com/weinberg/SQLToy/wiki/Two-Key-Concepts
Yes I did mean reversed.
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#134Earlier quoted context omitted.
Alright, I start typing out "SELECT" in my super smart IDE, how does it know which table to suggest columns from?
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)
#135Earlier quoted context omitted.
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.
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)
#136Look at Linq in C#, there they implemented it correctly and it's just awesome to use. It's so much more flexible and fun.
from ...
where ...
join ...
where ...
group ... by ...
where ...
select ...
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#137DuckDB does this. https://duckdb.org/2023/08/23/even-friendlier-sql.html#from-...
> This addresses one of the longest standing complaints about SQL, and the DuckDB team implemented it in 2 days. what a weird thing to say.