3 ms·
It's because the WHERE clause is evaluated before the SELECT. The reason that SQLite allows you to do that is because SQLite is much, much simpler than PgSQL, M
by hungerstrike 9y ago
It's because the WHERE clause is evaluated before the SELECT. The reason that SQLite allows you to do that is because SQLite is much, much simpler than PgSQL, MySQL and SQL Server (all of which don't allow you to do this).
http://tinman.cs.gsu.edu/~raj/sql/node22.html http://tinman.cs.gsu.edu/~raj/sql/node22.html
- danso 9y agoThat seems straightforward enough, don't know why I assumed SQLite's implementation of it was a feature as opposed to a consequence of its overall simplified model. I think I assumed/hoped that aliasing worked as a kind of function definition which WHERE could magically understand and evaluate.
- stats_n_trends 9y agoAs a counter point teradata (a ridiculously expensive closed source but fairly complex database) supports this feature. So it is definitely possible for this feature to be supported.
- combatentropy 9y agoYes. I wish SQL select-statements put the select-clause last: from people where name = 'Joe' select upper(name) as bigname 1. It would mirror the other clauses (insert, update, and delete) which all begin with the table name. 2. It would be easier on my head. I skip the select-clause anyway when reading SQL, then come back up to it at the end, when I know the columns' source. 3. It would show that using column aliases in the where-clause would fail (unless the database did some kind of two-pass processing).
- Volrath89 9y agoYou just described LINQ
- tux1968 9y agoYou would think that an initial pass of SELECT could be made only to note any aliases. It would be a much appreciated nod to usability.