Andreas Kretschmer wrote:
8q5tmky...@sneakemail.com <8q5tmky...@sneakemail.com> wrote:
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?
select a.* from article left join tags t on a.articleID=t.articleID where b.tag
= 'a';
select a.* from article left join tags t on a.articleID=t.articleID
where t.tag = 'a'
where not exists (select * from tags t2 where t2.articleID=a.articleID
and t2.tag = 'b');
Yeb
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql