Performing intersection without intersect operator
Performing intersection without intersect operator
От:
"Nacef LABIDI" <nacef.l@gmail.com>
Дата:
Hi all,
I want to perform an intersection between several select queries but without using the INTERSECT keyword.
select userid from orders where productid=1 INTERSECT select userid from orders where productid=2
I want to transform it without the INTERSECT.
Thanks to all
Nacef
I want to perform an intersection between several select queries but without using the INTERSECT keyword.
select userid from orders where productid=1 INTERSECT select userid from orders where productid=2
I want to transform it without the INTERSECT.
Thanks to all
Nacef
Re: Performing intersection without intersect operator
От:
"Oliveiros Cristina" <oliveiros.cristina@marktest.pt>
Дата:
Howdy, Nacef,
Try this,
SELECT a.userid
FROM orders a
JOIN orders b
USING (userid)
WHERE a.productid = 1
AND b.productid = 2
Best,
Oliveiros
----- Original Message -----From: Nacef LABIDISent: Tuesday, October 28, 2008 11:14 AMSubject: [SQL] Performing intersection without intersect operatorHi all,
I want to perform an intersection between several select queries but without using the INTERSECT keyword.
select userid from orders where productid=1 INTERSECT select userid from orders where productid=2
I want to transform it without the INTERSECT.
Thanks to all
Nacef
Re: Performing intersection without intersect operator
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Nacef LABIDI wrote: > I want to perform an intersection between several select queries but > without using the INTERSECT keyword. > > select userid from orders where productid=1 INTERSECT select userid from > orders where productid=2 > > I want to transform it without the INTERSECT. (select userid from orders where productid=1 UNION select userid from orders where productid=2) EXCEPT (select userid from orders where productid=1 EXCEPT select userid from orders where productid=2) EXCEPT (select userid from orders where productid=2 UNION select userid from orders where productid=1)