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

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: selecting rows tagged with "a" but not "b"
Date: 2010-02-01 14:14:53
Message-ID: 20100201141453.GA8857@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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';

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Yeb Havinga 2010-02-01 14:52:36 Re: selecting rows tagged with "a" but not "b"
Previous Message Milen A. Radev 2010-02-01 13:56:05 Re: selecting rows tagged with "a" but not "b"