UNION or LEFT JOIN?

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема UNION or LEFT JOIN?
Дата
Msg-id 20100216140814.GA22577@apartia.fr
обсуждение исходный текст
Ответы Re: UNION or LEFT JOIN?  (Oliveiros <oliveiros.cristina@gmail.com>)
Список pgsql-sql
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,


В списке pgsql-sql по дате отправления:

Предыдущее
От: Rob Sargent
Дата:
Сообщение: Re: Can i force deletion of dependent rows?
Следующее
От: Oliveiros
Дата:
Сообщение: Re: UNION or LEFT JOIN?