On Thu, 2007-02-01 at 21:18 +0100, Info wrote:
> If I use the following inner join of 3 tables:
> 
> SELECT  T1.A
> FROM    (T1 INNER JOIN T2 ON T1.A=T2.A) INNER JOIN T3 ON T1.B=T3.B
> 
> SQLite returns an error message saying that the column T1.A does not exist.
> If I run this statement on MysQL, Oracle or DB2, they accept it. And in
> fact, this is correct SQL.
> If I remove the brackets, SQLite also accepts it. But sometimes you want to
> work with brackets, if you are combining inner and left outer joins.
> 
> Any idea why this is not accepted by SQLite?

SQLite considers the tables within the brackets a sub-query. The
following two are handled in the same way internally:

   SELECT * FROM (abc, def);
   SELECT * FROM (SELECT * FROM abc, def);

In both cases the sub-query is handled as an anonymous table, it's
not possible to refer to it explicitly. The workaround is to name
it with an AS clause:

   SELECT T1T2.A
   FROM (T1 INNER JOIN T2 ON T1.A=T2.A) AS T1T2 ...

Dan.



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to