Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 0955E632CF2 for ; Tue, 16 Feb 2010 11:33:37 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 10332-06 for ; Tue, 16 Feb 2010 15:33:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pw0-f46.google.com (mail-pw0-f46.google.com [209.85.160.46]) by mail.postgresql.org (Postfix) with ESMTP id 049BF632CCC for ; Tue, 16 Feb 2010 11:33:25 -0400 (AST) Received: by pwj8 with SMTP id 8so876731pwj.19 for ; Tue, 16 Feb 2010 07:33:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=TSonaRxO8ZPJUYDxYC5m+Y3gsJlV+hJoXSJrgSmxL38=; b=Q6QoAIPILK3jGEcegRJrPcqCH7kbDjNrDeyqL4dqd2yzmSt3Lsesgo5ndurdsPPlBm +RTcSjHjyVdMcfdfln+E9F/6K1ZHy631MLCLdkpnFJRTDeO2YzfXppUR/ShlMBW0TiNX z+LLxV1EoFFR8+Kt56hbMsRL1OPUYhQQQC2m8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=VD7bKK3NhrmEAVCGJazNhLEvY7U1wZeoWuSWvbmIGNt2PAmeKTux+lIR9AbunI8V8R AyEIu3HpfJTs50CUD/nCgSaJfhf7WWje2T9rvbkdQo+Xj+xrRLioSGEH2tun1fGPzQut VHAjp6NR2rEj/IByBpGc7K+I7qHl2Eiul5dxE= MIME-Version: 1.0 Received: by 10.140.248.7 with SMTP id v7mr4379398rvh.237.1266334403768; Tue, 16 Feb 2010 07:33:23 -0800 (PST) In-Reply-To: <20100216140814.GA22577@apartia.fr> References: <20100216140814.GA22577@apartia.fr> Date: Tue, 16 Feb 2010 15:33:23 +0000 Message-ID: Subject: Re: UNION or LEFT JOIN? From: Oliveiros To: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=000e0cd17fe44db157047fb9745d X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.598 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201002/58 X-Sequence-Number: 33657 --000e0cd17fe44db157047fb9745d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 (=EEd_cabin,id_cruise), how do you know that cabin belongs to that cruise, = in this case, cruise n=BA 1? Best, Oliveiros 2010/2/16 Louis-David Mitterrand > > 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=B01 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 > --000e0cd17fe44db157047fb9745d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Louis-David,

Please advice me,

if some cabin doesn't hav= e a price i.e. it is not available, is there some way to tell
which crui= se it belongs to?

You have PRICE table which seems to me to be an as= sociative table between cruise and cabin, is this correct?

But, if the price doesn't have a register for that pair (=EEd_cabin= ,id_cruise), how do you know that cabin belongs to that cruise, in this cas= e, cruise n=BA 1?

Best,
Oliveiros

2010/2/16 Louis-David Mitterrand <vindex+lists-pgsql-sq= l@apartia.org>
Here is the basic= schema:

=A0-------------------------->id_ship>-----------------------
=A0| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|
[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 'cru= ise'

'cabin' belongs to a 'ship', so does 'cruise'

I'm trying to select all cabins of cruise N=B01 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

--000e0cd17fe44db157047fb9745d--