Re: UNION or LEFT JOIN? - Mailing list pgsql-sql

From Oliveiros
Subject Re: UNION or LEFT JOIN?
Date
Msg-id f54607781002160733l5e6f6d6fg1821106498ab464b@mail.gmail.com
Whole thread Raw
In response to UNION or LEFT JOIN?  (Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>)
Responses Re: UNION or LEFT JOIN?  (Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>)
List pgsql-sql
Louis-David, <br /><br />Please advice me,<br /><br />if some cabin doesn't have a price i.e. it is not available, is
theresome way to tell<br />which cruise it belongs to?<br /><br />You have PRICE table which seems to me to be an
associativetable between cruise and cabin, is this correct?<br /><br />But, if the price doesn't have a register for
thatpair (îd_cabin,id_cruise), how do you know that cabin belongs to that cruise, in this case, cruise nº 1?<br /><br
/>Best,<br/>Oliveiros<br /><br /><div class="gmail_quote"> 2010/2/16 Louis-David Mitterrand <span dir="ltr"><<a
href="mailto:vindex%2Blists-pgsql-sql@apartia.org"target="_blank">vindex+lists-pgsql-sql@apartia.org</a>></span><br
/><blockquoteclass="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;
padding-left:1ex;">Here is the basic schema:<br /><br />
 -------------------------->id_ship>-----------------------<br/>  |                                              
        |<br /> [SHIP]->id_ship->[CABIN]->id_cabin->[PRICE]<-id_cruise<-[CRUISE]<br /><br /> It's a
databaseof cruise prices.<br /><br /> Each 'price' object has a reference to 'cabin' and 'cruise'<br /><br /> 'cabin'
belongsto a 'ship', so does 'cruise'<br /><br /> I'm trying to select all cabins of cruise N°1 with prices OR nothing
if<br/> there is no price (meaning cabin not available). I want all cabins<br /> listed, price or no price.<br /><br />
Alsowhen doing the query I don't have the id_ship, only the id_cruise.<br /><br /> What is the best way of doing it?
UNIONor LEFT JOIN? I tried the latter<br /> without success and am unsure on how do do the former.<br /><br />
Thanks,<br/><font color="#888888"><br /> --<br /> Sent via pgsql-sql mailing list (<a
href="mailto:pgsql-sql@postgresql.org"target="_blank">pgsql-sql@postgresql.org</a>)<br /> To make changes to your
subscription:<br/><a href="http://www.postgresql.org/mailpref/pgsql-sql"
target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br/></font></blockquote></div><br /> 

pgsql-sql by date:

Previous
From: Louis-David Mitterrand
Date:
Subject: UNION or LEFT JOIN?
Next
From: Louis-David Mitterrand
Date:
Subject: Re: UNION or LEFT JOIN?