On Fri, Jul 15, 2005 at 09:59:27AM -0400, Tom Lane wrote: > Luca Pireddu <[EMAIL PROTECTED]> writes: > > So, am I wrong in expecting each strain record to appear only once in the > > result set? Or is there something wrong with PostgreSQL? > > Could we see a self-contained example (table definitions and sample data > as a SQL script)? I don't really have time to reverse-engineer a test > case from your description ...
I've been reverse-engineering and simplifying this. Here's something that I think is close: CREATE TABLE foo (id integer); CREATE TABLE bar (id1 integer, id2 integer); INSERT INTO foo VALUES (1); INSERT INTO bar VALUES (1, 1); INSERT INTO bar VALUES (2, 2); INSERT INTO bar VALUES (3, 1); SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT DISTINCT id1, id2 FROM bar) AS s); id ---- 1 1 (2 rows) SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT id1, id2 FROM bar) AS s); id ---- 1 (1 row) 8.0.3 and HEAD behave as shown. 7.4.8, 7.3.10, and 7.2.8 return a single row for both queries. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq