intersect within a subquery - Mailing list pgsql-general

From Phil Glatz
Subject intersect within a subquery
Date
Msg-id 5.1.0.14.2.20011121131859.031a86a8@flawless.net
Whole thread Raw
Responses Re: intersect within a subquery
List pgsql-general
I have a table cdb, indexed by cdb_id.
A second table map_flags to map to some other data.  It has a cdb_id field,
used to link to cdb.

I want to select a subset of cdb where records with a specific cdb_id is
present in two rows in map_flags, so I created a subquery to pull the
records from map_flags, using INTERSECT.  This query runs by itself ok, but
when I use it as a subquery, I get parse error at or near "intersect".

Isn't this legal?

SELECT c.cdb_id,c.company
FROM cdb c
WHERE c.cdb_id IN
   (SELECT m.cdb_id FROM map_flags m
   WHERE m.cflag_id=240
   INTERSECT
   SELECT m.cdb_id FROM map_flags m
   WHERE m.cflag_id=30)
ORDER BY c.company;


pgsql-general by date:

Previous
From: "Thomas T. Thai"
Date:
Subject: Re: PG vs MySQL
Next
From: Tom Lane
Date:
Subject: Re: intersect within a subquery