sorka wrote:
> I can't for the life of me figure this out. I'm trying to do a nested select
> like this:
>
> SELECT x FROM ((<select a> UNION <select b>) INTERSECT (<select c> UNION
> <select d>)) WHERE X=<some value>
>
> Each of the select a through d statements all return the same column x. If I
> remove the inner parentheses, it executes just fine but of course the
> results are wrong because C UNION D was not executed prior to the INTERSECT. 
>
> Also, in each sub select case, a, b, c, and d, are all selecting on
> different FTS3 tables using MATCH so I can't take advantage of FTS3's newer
> nested parentheses with AND OR NOT hence the nested selects since MATCH can
> only be used once per select.
>
> Any ideas? I really don't want to have to resort to using temporary tables.
>   
You need to use a separate select for each compound operator. Something 
like this should work as you expect.

    select x from
        (
        select x from
            (select x from a
            union
            select x from b)
            as ab
        intersect
        select x from
            (select x from c
            union
            select x from d)
            as cd
        ) as abcd
    where x > ?;

HTH
Dennis Cote

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to