From: Oliveiros <oliveiros.cristina@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: UNION or LEFT JOIN?
Date: Tue, 16 Feb 2010 15:33:23 +0000
Message-ID: <f54607781002160733l5e6f6d6fg1821106498ab464b@mail.gmail.com> (raw)
In-Reply-To: <20100216140814.GA22577@apartia.fr>
References: <20100216140814.GA22577@apartia.fr>
Louis-David,
Please advice me,
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?
You have PRICE table which seems to me to be an associative table between
cruise and cabin, is this correct?
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?
Best,
Oliveiros
2010/2/16 Louis-David Mitterrand
<vindex+lists-pgsql-sql@apartia.org<vindex%2Blists-pgsql-sql@apartia.org>
>
> Here is the basic schema:
>
> -------------------------->id_ship>-----------------------
> | |
> [SHIP]->id_ship->[CABIN]->id_cabin->[PRICE]<-id_cruise<-[CRUISE]
>
> It's a database of cruise prices.
>
> Each 'price' object has a reference to 'cabin' and 'cruise'
>
> 'cabin' belongs to a 'ship', so does 'cruise'
>
> I'm trying to select all cabins of cruise N°1 with prices OR nothing if
> there is no price (meaning cabin not available). I want all cabins
> listed, price or no price.
>
> Also when doing the query I don't have the id_ship, only the id_cruise.
>
> What is the best way of doing it? UNION or LEFT JOIN? I tried the latter
> without success and am unsure on how do do the former.
>
> Thanks,
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: oliveiros.cristina@gmail.com
Subject: Re: UNION or LEFT JOIN?
In-Reply-To: <f54607781002160733l5e6f6d6fg1821106498ab464b@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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