Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9D9C96321F8 for ; Tue, 16 Feb 2010 17:02: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 78097-10 for ; Tue, 16 Feb 2010 21:02:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sargon.lncsa.com (mail.lncsa.com [213.215.28.11]) by mail.postgresql.org (Postfix) with ESMTP id 066876321B8 for ; Tue, 16 Feb 2010 17:02:25 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id 0CF17300E35B for ; Tue, 16 Feb 2010 22:02:24 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lncsa.com Received: from sargon.lncsa.com ([127.0.0.1]) by localhost (sargon.lncsa.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AdfpUgUKLUbK for ; Tue, 16 Feb 2010 22:02:23 +0100 (CET) Received: from zenon.apartia.fr (zenon.apartia.fr [10.0.3.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "zenon.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by sargon.lncsa.com (Postfix) with ESMTP id E3363300E355 for ; Tue, 16 Feb 2010 22:02:23 +0100 (CET) Received: from delos.apartia.fr (delos.apartia.fr [10.0.3.107]) by zenon.apartia.fr (Postfix) with ESMTP id 545115B93F8C2 for ; Tue, 16 Feb 2010 22:02:23 +0100 (CET) Received: by delos.apartia.fr (Postfix, from userid 1000) id 42C22201FC2BF; Tue, 16 Feb 2010 22:02:23 +0100 (CET) Date: Tue, 16 Feb 2010 22:02:23 +0100 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: UNION or LEFT JOIN? Message-ID: <20100216210222.GA20610@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org References: <20100216140814.GA22577@apartia.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.413 tagged_above=-10 required=5 tests=AWL=0.186, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/59 X-Sequence-Number: 33658 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!