Re: SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3) - Mailing list pgsql-sql

From Tom Lane
Subject Re: SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3)
Date
Msg-id 11647.973874138@sss.pgh.pa.us
Whole thread Raw
In response to SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3)  (Christophe Boyanique <cboyanique@formanet.be>)
List pgsql-sql
Christophe Boyanique <cboyanique@formanet.be> writes:
> SELECT idProduct FROM products
>   WHERE idProduct IN
>     (SELECT id FROM orders WHERE ts>'2000-10-01 17:04:00'
>     UNION SELECT id FROM preorders WHERE ts>'2000-10-01 17:04:00')
>   ORDER by name;

> and I've got a parse error near UNION or SELECT depending of the

Current releases don't handle UNION in sub-selects.  7.1 will.

In the meantime, consider doing the UNION into a temp table and then
using that for the IN operator.
        regards, tom lane


pgsql-sql by date:

Previous
From: Christophe Boyanique
Date:
Subject: SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3)
Next
From: Christophe Boyanique
Date:
Subject: Re: SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3)