Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0A0EC475CAD for ; Wed, 14 Aug 2002 08:56:19 -0400 (EDT) Received: from mps2.plala.or.jp (mpsb-nat02.plala.or.jp [202.212.114.145]) by postgresql.org (Postfix) with ESMTP id C7126475C65 for ; Wed, 14 Aug 2002 08:56:17 -0400 (EDT) Received: from [192.168.0.4] ([218.47.225.244]) by mps2.plala.or.jp with ESMTP id <20020814125620.TZJM1768.mps2.plala.or.jp@[192.168.0.4]>; Wed, 14 Aug 2002 21:56:20 +0900 Date: Wed, 14 Aug 2002 21:57:02 +0900 From: Masaru Sugawara To: Andre Schubert Subject: Re: Need Help for select Cc: pgsql-sql@postgresql.org In-Reply-To: <20020814091053.1d3138db.andre@km3.de> References: <20020812151148.26186.qmail@web40013.mail.yahoo.com> <20020814091053.1d3138db.andre@km3.de> Errors-To: rk73@sea.plala.or.jp Message-Id: <20020814201310.C84C.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/223 X-Sequence-Number: 9069 On Wed, 14 Aug 2002 09:10:53 +0200 Andre Schubert wrote: > The ride side as follows. > Table d contains information about subitems. > Table c holds information about subitems and items of type bar. > Each subitem can have 0..n items bar selected. > > What i want is that a subitem is only activated for a foo item if > the foo-item has exactly selected the same bar items selected as > as the relation between table c and d. > > Example 1: > The foo-item A_Name1 has selected the bar-items 1 and 2. > The subitem D_Name1 is only activated for a foo-item if that foo-item > has selected the bar-items 1 and 2, this happens for A_Name1. > If this mention implies that the tuple of (1, 1) in the c is supposed to take precedence over that of (2, 1), 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