Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4DFFA633421 for ; Fri, 9 Oct 2009 21:26:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 64032-03 for ; Sat, 10 Oct 2009 00:26:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from megazone.bigpanda.com (unknown [64.147.171.210]) by mail.postgresql.org (Postfix) with ESMTP id A49E66332CA for ; Fri, 9 Oct 2009 21:26:35 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 0597035BD6; Fri, 9 Oct 2009 17:26:21 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 030E435BCF; Fri, 9 Oct 2009 17:26:21 -0700 (PDT) Date: Fri, 9 Oct 2009 17:26:20 -0700 (PDT) From: Stephan Szabo To: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= Cc: pgsql-sql@postgresql.org Subject: Re: Existential quantifier In-Reply-To: <86vdiop1hu.fsf@ds4.des.no> Message-ID: <20091009172456.C81911@megazone.bigpanda.com> References: <86bpkgqiv8.fsf@ds4.des.no> <20091009160318.J80119@megazone.bigpanda.com> <86vdiop1hu.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.499 tagged_above=-10 required=5 tests=BAYES_00=-2.599, RDNS_NONE=0.1 X-Spam-Level: X-Archive-Number: 200910/39 X-Sequence-Number: 33238 On Sat, 10 Oct 2009, [utf-8] Dag-Erling Sm=C3=B8rgrav wrote: > Stephan Szabo writes: > > Not at all tested as I don't have access to my db right now, but I thin= k > > something like one of these would work: > > > > select fs.film.title, fs.film.year > > from fs.film > > where exists(select 1 from fs.star where fs.film.id =3D fs.star.film > > and fs.star.last =3D 'Sheen'); > > Ah, that was exactly what I was looking for. > > > select fs.film.title, fs.film.year > > from fs.film > > where fs.film.id in (select fs.star.film where fs.star.last =3D 'Sheen= '); > > ITYM > > select fs.film.title, fs.film.year > from fs.film > where fs.film.id in ( > select fs.star.film from fs.star where fs.star.last =3D 'Sheen' > ); > > (missing FROM) Yeah, that'd be necessary. You might want to try them on a realistic data set to see how the various options are planned.