Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E4024632EA4 for ; Mon, 1 Feb 2010 10:15:09 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 88131-05 for ; Mon, 1 Feb 2010 14:14:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from vs137086.vserver.de (static-ip-62-75-137-86.inaddr.intergenia.de [62.75.137.86]) by mail.postgresql.org (Postfix) with ESMTP id 7E4D7632A73 for ; Mon, 1 Feb 2010 10:14:57 -0400 (AST) Received: (qmail 6017 invoked from network); 1 Feb 2010 15:14:54 +0100 Received: from p54b3802f.dip0.t-ipconnect.de (HELO a-kretschmer.de) (84.179.128.47) by static-ip-62-75-137-86.inaddr.intergenia.de with (AES256-SHA encrypted) SMTP; 1 Feb 2010 15:14:54 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1Nbx3F-0002JR-Eq for pgsql-sql@postgresql.org; Mon, 01 Feb 2010 15:14:53 +0100 Date: Mon, 1 Feb 2010 15:14:53 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: selecting rows tagged with "a" but not "b" Message-ID: <20100201141453.GA8857@tux> References: <11366-1265031099-334353@sneakemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <11366-1265031099-334353@sneakemail.com> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.213 tagged_above=-10 required=5 tests=AWL=0.386, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/14 X-Sequence-Number: 33613 8q5tmkyqry@sneakemail.com <8q5tmkyqry@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'; 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°