Dennis Cote <[EMAIL PROTECTED]> wrote: > > So SQLite should be sorting by the result column "c" not the column "c" > in the table T1 which it doing. >
My understand as of yesterday is that column name aliases are significant for ORDER BY, but not for WHERE, in standard SQL. This is not as crazy as it sounds, since ORDER BY is originally suppose to apply to result columns only. In other words, you are not suppose to be able to specify an ORDER BY of something that is not a result column. But SQLite (as well as other database engines) allow you to because people expect it. So ORDER BY applies to result columns and you would thus expect it to apply to result column aliases. But the WHERE clause applies to input tables. It does not necessarily see the result columns. The current name resolution rules for SQLite are that it first tries to resolve names using just the tables in the join. If that fails, then it looks at result column aliases. I think that approach continues to work on WHERE. But I need to reverse the search order on ORDER BY - the column aliases need to take precedence over tables in the join. -- D. Richard Hipp <[EMAIL PROTECTED]> ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------