X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 90EB1D1C509 for ; Thu, 31 Jul 2003 07:42:55 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 32084-02 for ; Thu, 31 Jul 2003 04:41:52 -0300 (ADT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id 9EA72D1C513 for ; Thu, 31 Jul 2003 04:42:52 -0300 (ADT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Thu Jul 31 09:42:49 2003 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id JAA28774; Thu, 31 Jul 2003 09:42:48 +0200 (METDST) Message-ID: <3F28C878.EE2EB806@rodos.fzk.de> Date: Thu, 31 Jul 2003 09:42:48 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: dave-ml@dribin.org, pgsql-sql@postgresql.org Subject: Re: One to many query question Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char 9C hex) in message header 'Received' Received: \234by rodos.fzk.de... ^ X-Archive-Number: 200307/480 X-Sequence-Number: 14594 > > On Wed, Jul 30, 2003 at 05:26:23PM -0400, Dmitry Tkach wrote: > > >How do I write a query to find all CDs that are NOT Rock? > > > > > What about > > select * from cd where not exists (select 1 from cd_genres where cd_id > > = cd.id and genre='Rock')? > > Thanks everyone! This did indeed work, and it does seem clearer. I > never knew about EXISTS before. How portable is this? I'm interested > in supporting PostgreSQL and MS SQL Server for now, and possibly > Oracle and MySQL in the future. > It should be portable completely. It's SQL standard. Regards, Christoph