Re: One to many query question

From: Dave Dribin <dave-ml(at)dribin(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: One to many query question
Date: 2003-07-30 22:33:06
Message-ID: 20030730223306.GG1383@neo.realtors.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

-Dave

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message 2000info 2003-07-31 00:25:38 Unsubscribe
Previous Message Eric Clark 2003-07-30 21:42:06 Re: One to many query question