From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Luca Pireddu <luca(at)cs(dot)ualberta(dot)ca>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: problem (bug?) with "in (subquery)" |
Date: | 2005-07-15 14:10:37 |
Message-ID: | 20050715141037.GA30461@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, Jul 15, 2005 at 09:59:27AM -0400, Tom Lane wrote:
> Luca Pireddu <luca(at)cs(dot)ualberta(dot)ca> 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Dinesh Pandey | 2005-07-15 14:38:50 | Postgres for Fedora Core 2 OS **************** |
Previous Message | Tom Lane | 2005-07-15 13:59:27 | Re: problem (bug?) with "in (subquery)" |