pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: anssiman@my-deja.com
To: pgsql-sql@postgresql.org
Subject: Subquery with IN or EXISTS
Date: 26 Sep 2001 07:24:41 -0700
Message-ID: <8b9752ea.0109260624.5b0d2c20@posting.google.com> (raw)

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)?



view thread (3+ messages)  latest in thread

Message-ID: <8b9752ea.0109260624.5b0d2c20@posting.google.com>
Permalink:  ../8b9752ea.0109260624.5b0d2c20@posting.google.com/
Also on:    postgresql.org/message-id/8b9752ea.0109260624.5b0d2c20@posting.google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: anssiman@my-deja.com
  Subject: Re: Subquery with IN or EXISTS
  In-Reply-To: <8b9752ea.0109260624.5b0d2c20@posting.google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox