News for hackers. Stuff that matters.
Re:Left to Right Programming by marcosdumay on Monday August 18, 2025 @04:54PM (#44945231)
The order should be starting on FROM, followed by any sequences of whatever clauses (except for FROM), always creating an intermediary result-set.

FROM table -- equivalent to today's select * from table

SELECT a, 1 as b, c, d -- equivalent to select ... from table

WHERE a in (1, 2, 3) -- the above with the where

GROUP BY c -- the above with the group by

WHERE sum(d) > 100 -- the above with having sum(d) > 100

SELECT count(a distinct) qt_a, sum(b) as count, sum(d) total_d -- the above being a sub-query this selects from

Re:Left to Right Programming by sgarland on Monday August 18, 2025 @05:02PM (#44945295)
> always creating an intermediary result-set

You want the DB to first run SELECT * FROM <table>, and then start operating on that?

Re:Left to Right Programming by kerkeslager on Monday August 18, 2025 @05:19PM (#44945456)
Obviously not, and bringing this up as if it's a gotcha just shows you aren't keeping up with the conversation. Try less to correct people and more to understand people.

It's about how humans think about it, not about how the computer executes it.

Re:Left to Right Programming by sgarland on Monday August 18, 2025 @05:29PM (#44945544)
How else do you read what they wrote?
Re:Left to Right Programming by eyelidlessness on Monday August 18, 2025 @06:07PM (#44945818)
I read it as describing their preferred mental model for declaring a result set, which is different from describing their preferred behavior to produce it. This seems clear to me in wording and context; it’s also broadly consistent with how SQL is understood, and how it is generally implemented.
Re:Left to Right Programming by dragonwriter on Monday August 18, 2025 @10:35PM (#44947681)
Presumably, the intermediate result sets would necessary be materialized, only logical.
Re:Left to Right Programming by AdieuToLogic on Monday August 18, 2025 @10:30PM (#44947652)
How would this approach support SQL constructs such as the HAVING[0] clause? Or is that what you meant by:

  WHERE sum(d) > 100 -- the above with having sum(d) > 100
0 - https://www.w3schools.com/sql/sql_having.asp
Re:Left to Right Programming by Pxtl on Tuesday August 19, 2025 @05:43AM (#44949881)
My other big dream would be allowing multiple WHERE clauses that would be semantically ANDed together because that's what would happen if you filtered a result set twice.
Re:Left to Right Programming by kerkeslager on Tuesday August 19, 2025 @10:37AM (#44952036)
Yes! I've always been annoyed by this.
Re:Left to Right Programming by marcosdumay on Tuesday August 19, 2025 @11:02AM (#44952380)
Yes, by whatever clauses I also meant repeating ones.

SQL has a conceptual issue with repeating group by clauses, so maybe not that one (or maybe we should fix the conceptual issues). But any other, including the limiting and offset ones.