X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D92A7329D91 for ; Mon, 4 Oct 2004 15:17:28 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22332-08 for ; Mon, 4 Oct 2004 14:17:16 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C4E81329C70 for ; Mon, 4 Oct 2004 15:17:19 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i94EHG1I020689; Mon, 4 Oct 2004 10:17:16 -0400 (EDT) To: Markus Bertheau Cc: pgsql-sql Subject: Re: Difference between IN and JOIN In-reply-to: <1096879190.2651.8.camel@dicaprio.akademie1.de> References: <1096879190.2651.8.camel@dicaprio.akademie1.de> Comments: In-reply-to Markus Bertheau message dated "Mon, 04 Oct 2004 10:39:50 +0200" Date: Mon, 04 Oct 2004 10:17:16 -0400 Message-ID: <20688.1096899436@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/21 X-Sequence-Number: 19124 Markus Bertheau 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