From: Milen A. Radev <milen@radev.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: selecting rows tagged with "a" but not "b"
Date: Mon, 01 Feb 2010 15:56:05 +0200
Message-ID: <4B66DD75.5010506@radev.net> (raw)
In-Reply-To: <11366-1265031099-334353@sneakemail.com>
References: <11366-1265031099-334353@sneakemail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: milen@radev.net
Subject: Re: selecting rows tagged with "a" but not "b"
In-Reply-To: <4B66DD75.5010506@radev.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox