Earlier quoted context omitted.
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.
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.
Shouldn't FROM come before SELECT in SQL? (2011)
121–130 of 137 posts
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#122Earlier quoted context omitted.
It would be really nice if PostgreSQL and sqlite implemented this natively as it really feels how SQL should be (re)designed today. It also makes writing complex queries easier as it would be possible to split out actions in multiple steps where you can see what columns and types you have created (and found) so far. Complex SQL is like complex C++: works if you get it right, but no help whatsoever for figuring out wh…
On one hand SQL has some oddities, on the other I'd rather there not be yet more different-but-equivalent ways to do things in SQL. I think the current state is good enough.
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#123Earlier quoted context omitted.
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.
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)
#124Earlier quoted context omitted.
that may very well be the case but perhaps there could be an evolution of the language because for newcomers the idea that the from clause is evaluated/executed/defined first is a pain point. Newbies I help sometimes wonder why things they reference in the SELECT part aren't visible/available in the FROM clause and that's because one is selecting the result of FROM ... JOIN ... WHERE etc anyway
> he idea that the from clause is evaluated/executed/defined first is a pain point Maybe my brain is broken by years of SQL and from learning English as a second language. But isn’t this supposed to follow a fairly mundane English sentence structure? “Select socks and pants from drawer”. If you started saying “from drawer select socks and pants”, wouldn’t that feel like a weird sentence structure to most people?
Codd's original vision would have seen that expressed as something like:
RANGE DRAWER D
GET W (D#,SOCKS,PANTS)
DELETE D:(D.MONEY=1)Re: Shouldn't FROM come before SELECT in SQL? (2011)
#125Earlier quoted context omitted.
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?
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)
#126FROM is not a command, it's a parameter, and an optional one at that. This is valid SQL. SELECT 1; The SQL commands are SELECT, UPDATE, INSERT, etc. Therefore, those commands should be the first thing in an instruction. If you have a file full of SQL, you probably want all the lines to start with those commands. Gonna be pretty weird to read if you have both SELECT and UPDATE lines that start with FROM. Probably diff…
FROM ℝ SELECT 1 ? :-)
ORDER DESC
COUNT(*)
I can't find anything after a quick search except recursive views that must terminate (therefore aren't infinite)Re: Shouldn't FROM come before SELECT in SQL? (2011)
#127My 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.
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#128Earlier quoted context omitted.
FROM ℝ SELECT 1 ? :-)
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)
> 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)
#129"The syntax is meant to resemble English", obviously. The link to https://www.lib.umn.edu/collections/special?id=291 is dead, though?
Re: Shouldn't FROM come before SELECT in SQL? (2011)
#130Earlier quoted context omitted.
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.
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.