X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 1A5699DD745 for ; Fri, 13 Jan 2006 11:23:03 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26411-02-2 for ; Fri, 13 Jan 2006 11:23:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from bostoncoop.net (dsl001-169-236.bos1.dsl.speakeasy.net [72.1.169.236]) by postgresql.org (Postfix) with ESMTP id 563F09DD735 for ; Fri, 13 Jan 2006 11:22:57 -0400 (AST) Received: from [10.1.27.37] (metcalfe.wolfgreenfield.com [12.45.255.66]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by bostoncoop.net (Postfix) with ESMTP id 0001AA03E9; Fri, 13 Jan 2006 10:23:00 -0500 (EST) Message-ID: <43C7C5D1.9030600@rosi-kessel.org> Date: Fri, 13 Jan 2006 10:22:57 -0500 From: Adam Rosi-Kessel User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Michael Glaesemann Cc: pgsql-sql@postgresql.org Subject: Re: ORDER BY does not work as expected with multiple joins References: <43C7BA12.90103@rosi-kessel.org> <3AA68074-D959-442F-8329-79D09D5F9129@myrealbox.com> In-Reply-To: <3AA68074-D959-442F-8329-79D09D5F9129@myrealbox.com> X-Enigmail-Version: 0.93.2.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigD6C93D6CEE2A5D7AB63C2C46" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200601/63 X-Sequence-Number: 23852 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD6C93D6CEE2A5D7AB63C2C46 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for your helpful response. Michael Glaesemann wrote: > I don't seem to have a problem with the ordering given your data. I'm > not sure why you're doing right and left joins, though. You might want > to use left joins if you have NULL id1 or id2, but otherwise just plain= > JOIN should work fine. I've included both your SELECT (slightly modifie= d > to avoid using key words) and how I'd probably right the statement. id1 will always have a value but id2 can be NULL. So should I do a left J= OIN on id2 but a plain JOIN on id1? Is there a disadvantage to using a left J= OIN where it is not necessary? Adam --------------enigD6C93D6CEE2A5D7AB63C2C46 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFDx8XRdTf3ZklQ6qYRAjVmAJ4p4WSb32N8qVh+e1q86pFikozUIgCfdNgt zMThkSiXTtT767l1qrtA/gE= =Fse1 -----END PGP SIGNATURE----- --------------enigD6C93D6CEE2A5D7AB63C2C46--