On Mon, 27 Jan 2014 18:57:26 +0100
Jean-Christophe Deschamps <[email protected]> wrote:
> (
> select * from A where x in (subselectA)
> left outer join
> select * from B where y in (subselectB)
> )
>
> union all
>
> ( -- <-- error
> select * from B where y in (subselectC)
> left outer join
> select * from A where x in (subselectD)
> )
Perhaps you want:
select * from (
select * from A where x in (subselectA)
left outer join (
select * from B where y in (subselectB)
) as a
on -- something
) as A1
UNION ALL
select * from (
select * from B where y in (subselectC)
left outer join (
select * from A where x in (subselectD)
) as b
on -- something
) as B1
JOIN takes tables (or table-like objects) as operands. SELECT does not
yield a table unless it's wrapped in parenthesis.
(I generally put UNION in uppercase to make it stand out, lest on a
quick scan it seem like two separate statements.)
HTH.
--jkl
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users