Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17353475EA8 for ; Wed, 28 Aug 2002 16:21:33 -0400 (EDT) Received: from mta5.snet.net (mta5.snet.net [204.60.203.77]) by postgresql.org (Postfix) with ESMTP id 7825F475840 for ; Wed, 28 Aug 2002 16:21:32 -0400 (EDT) Received: from pop.snet.net ([204.60.203.73]) by mta5.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id g7SKIZt0019188; Wed, 28 Aug 2002 16:18:35 -0400 (EDT) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id g7SKLTT0026083; Wed, 28 Aug 2002 16:21:29 -0400 (EDT) Subject: Re: select question From: Wei Weng To: gry@ll.mit.edu Cc: pgsql-sql@postgresql.org In-Reply-To: <20020828161241.50a8512d.gry@ll.mit.edu> References: <20020828161241.50a8512d.gry@ll.mit.edu> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 28 Aug 2002 16:21:31 -0400 Message-Id: <1030566092.24266.1.camel@Monet> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/406 X-Sequence-Number: 9252 You can use this query SELECT * FROM T WHERE run = 'a' AND wafer = 1 AND test = 'foo' UNION SELECT * FROM T WHERE run = 'a' AND wafer = 2 AND test = 'foo' UNION SELECT * FROM T WHERE run = 'a' AND wafer = 3 AND test = 'foo' UNION SELECT * FROM T WHERE run = 'a' AND wafer = 3 AND test = 'bar' On Wed, 2002-08-28 at 16:12, george young wrote: > [postgreql 7.2, linux] > I have a table T with columns run, wafer, and test: > T(run text, wafer int, test text) > Given a run and a set of wafers, I need the set of tests that match > *all* the specified wafers: > > run wafer test > a 1 foo > a 2 foo > a 3 foo > a 3 bar > > E.g. > Given run 'a' and wafers (1,3) I should get one row: foo, since only foo matches both 1 and 3. > Given run 'a' and wafers (3) I should get two rows: foo,bar, since both foo and bar match 3. > > Is there some neat way to do this in a single query? > > Puzzled, > George > > > -- > I cannot think why the whole bed of the ocean is > not one solid mass of oysters, so prolific they seem. Ah, > I am wandering! Strange how the brain controls the brain! > -- Sherlock Holmes in "The Dying Detective" > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > -- Wei Weng Network Software Engineer KenCast Inc.