pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Markus Bertheau <twanger@bluetwanger.de>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Difference between IN and JOIN
Date: Mon, 04 Oct 2004 10:17:16 -0400
Message-ID: <20688.1096899436@sss.pgh.pa.us> (raw)
In-Reply-To: <1096879190.2651.8.camel@dicaprio.akademie1.de>
References: <1096879190.2651.8.camel@dicaprio.akademie1.de>

Markus Bertheau <twanger@bluetwanger.de> writes:
> I lately wondered if there is a difference between a JOIN and a IN in
> queries similar to the following:

> SELECT f1 FROM t1 JOIN t2 ON (t.f2 = t2.f2) WHERE t2.f3 = x

> SELECT f1 FROM t1 WHERE t1.f2 IN (SELECT f2 FROM t2 WHERE f3 = x)

> As I see it there's no semantic difference between the two.

There's plenty of difference, if t2 contains repeated occurrences of f2
values.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <20688.1096899436@sss.pgh.pa.us>
Permalink:  ../20688.1096899436@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20688.1096899436@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, twanger@bluetwanger.de
  Subject: Re: Difference between IN and JOIN
  In-Reply-To: <20688.1096899436@sss.pgh.pa.us>

* 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