Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 122CA476313 for ; Wed, 28 Aug 2002 16:12:47 -0400 (EDT) Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by postgresql.org (Postfix) with ESMTP id 65F65475840 for ; Wed, 28 Aug 2002 16:12:46 -0400 (EDT) Received: (from smtp@localhost) by ll.mit.edu (8.11.3/8.8.8) id g7SKCkM17762 for ; Wed, 28 Aug 2002 16:12:46 -0400 (EDT) Received: from sty.llan.ll.mit.edu( ), claiming to be "sty" via SMTP by llpost, id smtpdAAA2AaWEH; Wed Aug 28 16:12:42 2002 Date: Wed, 28 Aug 2002 16:12:41 -0400 From: george young To: pgsql-sql@postgresql.org Subject: select question Message-Id: <20020828161241.50a8512d.gry@ll.mit.edu> Reply-To: gry@ll.mit.edu Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 0.7.8 (GTK+ 1.2.8; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/405 X-Sequence-Number: 9251 [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"