X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A83DE474E4F for ; Thu, 13 Feb 2003 07:05:37 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 046FB474E42 for ; Thu, 13 Feb 2003 07:05:37 -0500 (EST) Received: from klaster.net (pb145.krakow.cvx.ppp.tpnet.pl [213.76.37.145]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id F2DFB2B884; Thu, 13 Feb 2003 12:57:31 +0100 (CET) Message-ID: <3E4B89E0.2060206@klaster.net> Date: Thu, 13 Feb 2003 13:04:48 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: wahab@mimos.my Cc: pgsql-sql@postgresql.org Subject: Re: UNION or UNION ALL References: <3E4B5CC3.2C10E63A@mimos.my> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/285 X-Sequence-Number: 11683 Abdul Wahab Dahalan wrote: > I've 3 tables A,B,C > records in table A like: > id name > b1 abc > b2 xyz > b3 rst > > records in table B like: > id type > b1 logistics > b1 importer > b2 logistics > b3 logistics > b3 exporter > > records in table C like: > id offer title > b1 sell car > b1 buy car > b1 sell van > b2 sell car > > How shoul I do a query so that I can get a result like > (The query will be based on B.type ='logistics') > id name offer > b1 abc sell > b1 abc buy > b1 abc sell > b2 xyz sell > b3 rst -- > > Any help very much appricated select id, name, offer from A join B using (_id) left join C using (_id) where type='logistics'; As you see, you don't need any UNION ;-) BTW - please - turn off HTML format in your mail client. Regards, Tomasz Myrta