selecting rows tagged with "a" but not "b"

From: 8q5tmkyqry(at)sneakemail(dot)com
To: pgsql-sql(at)postgresql(dot)org
Subject: selecting rows tagged with "a" but not "b"
Date: 2010-02-01 13:31:38
Message-ID: 11366-1265031099-334353@sneakemail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I have a two tables:

article
articleID, name, content

tags
articleID, tag

I want to find all articles that are tagged with "a" but not "b"

how do I do this?

what I'd like to do is:

<wishful thinking>
select articleID from tags where tag="a"
SUBTRACT
select articleID from tags where tab="b"
</wishful thinking>

how do I do this in real SQL?

thanks

Darrell

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Oliveiros C, 2010-02-01 13:44:57 Re: selecting rows tagged with "a" but not "b"
Previous Message Sam Mason 2010-02-01 12:08:49 Re: combine SQL SELECT statements into one