Andreas Kretschmer wrote:
[email protected] <[email protected]> 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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql