Re: selecting rows tagged with "a" but not "b" - Mailing list pgsql-sql

From Milen A. Radev
Subject Re: selecting rows tagged with "a" but not "b"
Date
Msg-id 4B66DD75.5010506@radev.net
Whole thread Raw
In response to selecting rows tagged with "a" but not "b"  (8q5tmkyqry@sneakemail.com)
List pgsql-sql
8q5tmkyqry@sneakemail.com написа:
> 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?

Replace "SUBSTRACT" with "EXCEPT" 
(http://www.postgresql.org/docs/current/static/sql-select.html#SQL-EXCEPT).




-- 
Milen A. Radev


pgsql-sql by date:

Previous
From: 8q5tmkyqry@sneakemail.com
Date:
Subject: selecting rows tagged with "a" but not "b"
Next
From: "Oliveiros C,"
Date:
Subject: Re: selecting rows tagged with "a" but not "b"