Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6B24B4763B1 for ; Wed, 14 Aug 2002 18:56:49 -0400 (EDT) Received: from mps4.plala.or.jp (mpsb-nat02.plala.or.jp [202.212.114.145]) by postgresql.org (Postfix) with ESMTP id 1E207475994 for ; Wed, 14 Aug 2002 18:56:48 -0400 (EDT) Received: from [192.168.0.4] ([218.47.225.244]) by mps4.plala.or.jp with ESMTP id <20020814225649.XRYB22328.mps4.plala.or.jp@[192.168.0.4]>; Thu, 15 Aug 2002 07:56:49 +0900 Date: Thu, 15 Aug 2002 07:57:31 +0900 From: Masaru Sugawara To: Andre Schubert Subject: Re: Need Help for select Cc: pgsql-sql@postgresql.org In-Reply-To: <20020814160421.2c75727e.andre@km3.de> References: <20020814201310.C84C.RK73@sea.plala.or.jp> <20020814160421.2c75727e.andre@km3.de> Errors-To: rk73@sea.plala.or.jp Message-Id: <20020815072303.C857.RK73@sea.plala.or.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.05.03 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/240 X-Sequence-Number: 9086 On Wed, 14 Aug 2002 16:04:21 +0200 Andre Schubert wrote: > > > > > > If this mention implies that the tuple of (1, 1) in the c is supposed ^^ b > > to take precedence over that of (2, 1), > > I want to compare if a tuple in c exist in b for each c.d_id and b.a_id. > In c exists 3 tuples: (1,2), (3,4), (5) > and want to find these tuples in b. I were able to catch what conditions join b to c. I try to think again. > > select a.name,d.name from a,b,c,d where "tuple found in b" = "tuple found in c" and b.a_id = a.id and c.d_id = d.id > > My english is not so good, but i hope you understand what i want to do. > > Thanks in advance > > > > > > > SELECT a.name, d.name > > FROM (SELECT DISTINCT min(b.a_id) AS a_id, c.d_id > > FROM b, c > > WHERE b.c_id = c.b_id > > GROUP BY b.c_id, c.d_id > > ) AS t, > > a, > > d > > WHERE a.id = t.a_id > > AND d.id = t.d_id > > > > Regards, Masaru Sugawara