pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
UNION or UNION ALL 2+ messages / 2 participants [nested] [flat]
* UNION or UNION ALL @ 2003-02-13 08:52 Abdul Wahab Dahalan <wahab@mimos.my> 2003-02-13 12:04 ` Re: UNION or UNION ALL Tomasz Myrta <jasiek@klaster.net> 0 siblings, 1 reply; 2+ messages in thread From: Abdul Wahab Dahalan @ 2003-02-13 08:52 UTC (permalink / raw) To: pgsql-sql 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: UNION or UNION ALL 2003-02-13 08:52 UNION or UNION ALL Abdul Wahab Dahalan <wahab@mimos.my> @ 2003-02-13 12:04 ` Tomasz Myrta <jasiek@klaster.net> 0 siblings, 0 replies; 2+ messages in thread From: Tomasz Myrta @ 2003-02-13 12:04 UTC (permalink / raw) To: wahab@mimos.my; +Cc: pgsql-sql 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-02-13 12:04 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2003-02-13 08:52 UNION or UNION ALL Abdul Wahab Dahalan <wahab@mimos.my> 2003-02-13 12:04 ` Tomasz Myrta <jasiek@klaster.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox