Received: from Main.eurocom.od.ua (Main.EuroCom.Od.UA [212.15.128.6]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f846Ns787171 for ; Tue, 4 Sep 2001 02:23:54 -0400 (EDT) (envelope-from gsmith@eurocom.od.ua) Received: from eurocom.od.ua (Farhost.eurocom.od.ua [212.15.128.162]) by Main.eurocom.od.ua (8.11.6/8.11.6) with ESMTP id f846NjJ08211 for ; Tue, 4 Sep 2001 09:23:45 +0300 Message-ID: <3B94736F.999ACBAF@eurocom.od.ua> Date: Tue, 04 Sep 2001 09:23:43 +0300 From: "Vladimir V. Zolotych" Organization: Eurocom X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.3.0 i586) X-Accept-Language: ru, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Need help in composing PostgreSQL query Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Archive-Number: 200109/15 X-Sequence-Number: 4661 Hi Please help me compose the query in PostgreSQL. Using PostgreSQL 7.1.2. Suppose relations A and B have columns: {X1, X2, ..., Xm, Y1, Y2, ..., Yn} and {Y1, Y2, ..., Yn} Attributes Y1, Y2, ..., Yn are common for both relations and have the same type in both. How can I define in PostgreSQL the query producing relation with columns X1,X2,...,Xm containing all those tuples satisfying conditon: relation A contains tupple {x1,x2,...xm,y1,y2,...,yn} for _each_ tupple {y1,y2,...,yn} in relation B ? Where x1 denotes particular value of colum X1 etc. For example: consider two tables DEND and DOR. DEND DOR s | p p ----+---- ---- s1 | p1 p1 s1 | p2 p2 s1 | p3 p3 s1 | p4 p4 s1 | p5 p5 s1 | p6 p5 s2 | p1 (6 rows) s2 | p2 s3 | p2 s4 | p2 s4 | p4 s4 | p5 (12 rows) For such tables our desired query should return: s ---- s1 Thanks in advance. -- Vladimir Zolotych gsmith@eurocom.od.ua