Subquery with IN or EXISTS - Mailing list pgsql-sql

From anssiman@my-deja.com (A. Mannisto)
Subject Subquery with IN or EXISTS
Date
Msg-id 8b9752ea.0109260624.5b0d2c20@posting.google.com
Whole thread Raw
List pgsql-sql
Hello,

does anybody know why this:
SELECT * FROM tab WHERE col1 IN (SELECT col2 FROM TAB2)

equals this:
SELECT * FROM tab WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 =
col2)

but this:
SELECT * FROM tab WHERE col1 IN (SELECT col2 FROM TAB2 WHERE
col3='huu')

equals _NOT_ this:
SELECT * FROM tab WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 =
col2 AND col3='huu')

E.g. resultset is not the same in last two statements.
Can I get same set as IN statement somehow using EXISTS (performance
issue)?


pgsql-sql by date:

Previous
From: Andy Hibbins
Date:
Subject: Re: getting some tech skills?
Next
From: Rick Robino
Date:
Subject: Re: Request for book reviews/comments