X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B43F4DBE0A for ; Fri, 25 Nov 2005 15:54:02 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76711-05 for ; Fri, 25 Nov 2005 19:54:01 +0000 (GMT) X-Greylist: delayed 03:00:52.500467 by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 8882CDBDF8 for ; Fri, 25 Nov 2005 15:53:58 -0400 (AST) Received: from kraid.nerim.net (smtp-105-friday.nerim.net [62.4.16.105]) by svr2.postgresql.org (Postfix) with ESMTP id CF5BEF0B16 for ; Fri, 25 Nov 2005 16:53:03 +0000 (GMT) Received: from jobmare.clarisys.lan (claridsl512.net1.nerim.net [213.41.148.137]) by kraid.nerim.net (Postfix) with ESMTP id DCAB940F41; Fri, 25 Nov 2005 17:52:57 +0100 (CET) Received: from day by jobmare.clarisys.lan with local (Exim 4.54) id 1Efgol-000218-Ga; Fri, 25 Nov 2005 17:52:59 +0100 Date: Fri, 25 Nov 2005 17:52:59 +0100 From: David Pradier To: pgsql-sql@postgresql.org Subject: Order of precedence between AND and OR. Message-ID: <20051125165259.GE4482@clarisys.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/246 X-Sequence-Number: 23497 Hi everybody, during the code inspection due to our migration to 8.1, I found a piece of SQL code written like this : WHERE a AND b OR c AND d Now, I know that AND and OR are commutative because it's written in the docs. But what I couldn't find is if there is an order of precedence between AND and OR, that is if the AND expression is calculated before the OR one, or anyelse way. Could somebody tell me or point me to the right doc ? Thanks in advance, David -- David Pradier -- Directeur Technique de Clarisys Informatique -- Chef de projet logiciels libres / open-source