Andreas Kretschmer wrote:
> 8q5tmkyqry(at)sneakemail(dot)com <8q5tmkyqry(at)sneakemail(dot)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