Re: Performing intersection without intersect operator - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: Performing intersection without intersect operator
Date
Msg-id 4906FEA8.4020901@gmx.net
Whole thread Raw
In response to Performing intersection without intersect operator  ("Nacef LABIDI" <nacef.l@gmail.com>)
List pgsql-sql
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)


pgsql-sql by date:

Previous
From: "Oliveiros Cristina"
Date:
Subject: Re: Performing intersection without intersect operator
Next
From: Tom Lane
Date:
Subject: Re: How to hand over array as variable in plpgsql function?