Re: UNION or LEFT JOIN?

From: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: UNION or LEFT JOIN?
Date: 2010-02-16 21:02:23
Message-ID: 20100216210222.GA20610@apartia.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Feb 16, 2010 at 03:33:23PM +0000, Oliveiros wrote:
> Louis-David,
>
> Please advice me,

Hi Oliveiros,

> if some cabin doesn't have a price i.e. it is not available, is there some
> way to tell
> which cruise it belongs to?

In fact a cabin belongs to a ship and CAN be associated to a 'cruise'
event with a price(id_cruise,id_cabin) object.

> You have PRICE table which seems to me to be an associative table between
> cruise and cabin, is this correct?

Yes,

> But, if the price doesn't have a register for that pair
> (îd_cabin,id_cruise), how do you know that cabin belongs to that cruise, in
> this case, cruise nº 1?

I am trying to display a list of all cabins of a ship for a certain
cruise even if some prices are missing, so the user sees what cabins are
not available.

After much trial and error I was finally able to build a left join query
that works.

Thanks a lot for offering your help!

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tim Landscheidt 2010-02-16 21:38:19 Re: UNION or LEFT JOIN?
Previous Message Oliveiros 2010-02-16 15:33:23 Re: UNION or LEFT JOIN?