Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 6449A6330D1 for ; Fri, 9 Oct 2009 20:54:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 77486-04 for ; Fri, 9 Oct 2009 23:54:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tim.des.no (tim.des.no [194.63.250.121]) by mail.postgresql.org (Postfix) with ESMTP id A9862632BB0 for ; Fri, 9 Oct 2009 20:54:25 -0300 (ADT) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 2BD9D6D41B; Fri, 9 Oct 2009 23:54:22 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id D4A6084503; Sat, 10 Oct 2009 01:54:21 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Stephan Szabo Cc: pgsql-sql@postgresql.org Subject: Re: Existential quantifier References: <86bpkgqiv8.fsf@ds4.des.no> <20091009160318.J80119@megazone.bigpanda.com> Date: Sat, 10 Oct 2009 01:54:21 +0200 In-Reply-To: <20091009160318.J80119@megazone.bigpanda.com> (Stephan Szabo's message of "Fri, 9 Oct 2009 16:06:56 -0700 (PDT)") Message-ID: <86vdiop1hu.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/38 X-Sequence-Number: 33237 Stephan Szabo writes: > Not at all tested as I don't have access to my db right now, but I think > 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) DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no