X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 452ADCC323 for ; Tue, 15 Jul 2003 13:43:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 88901-03 for ; Tue, 15 Jul 2003 13:43:26 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id C67E7CC2D8 for ; Tue, 15 Jul 2003 10:43:01 -0300 (ADT) Received: (qmail 10766 invoked by uid 500); 15 Jul 2003 13:47:47 -0000 Date: Tue, 15 Jul 2003 08:47:47 -0500 From: Bruno Wolff III To: teknokrat Cc: pgsql-sql@postgresql.org Subject: Re: help with troublesome query Message-ID: <20030715134747.GC10467@wolff.to> Mail-Followup-To: teknokrat , pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/169 X-Sequence-Number: 14283 On Tue, Jul 15, 2003 at 14:26:16 +0100, teknokrat wrote: > I have three tables customers which 1-many with requests which is 1-1 > with applications. all customers have at least one request but not all > requests have an application. > > I want a query to return all the customers and their application data if > they have any ( or else null). So this is like a left join of customers > with applications but I do not want multiple rows of customers UNLESS > they have an application. I think you want to first do an inner join of requests and applications and then left join the customers and the previous join.