From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Casey Allen Shobe <cshobe(at)secureworks(dot)com> |
Cc: | "'pgsql-bugs(at)postgresql(dot)org'" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: Parethesis don't work correctly in where clause |
Date: | 2003-04-17 10:48:08 |
Message-ID: | 1050576488.27275.99.camel@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, 2003-04-17 at 09:23, Casey Allen Shobe wrote:
> I have a query with:
> where "n"."revision" = 2
...
> However, if I add:
> and (
> "t"."name" = 'nibc'
> and "n"."identifier" = 1274
> ) or (
> "t"."name" = 'client'
> and "n"."identifier" = 383
> )
> PostgreSQL returns only the revision 2 tuple for nibc 1274, but also a
> revision 1 tuple for client 383. ONLY things matching revision 2 should be
> found, but for some reason the "n"."revision" = 2 isn't being applied
> globally, but only to the first set of parenthesis.
This is simply a matter of boolean logic and the precedence of the AND
and OR operators.
If you instead force the operator precedence and add
and ((
"t"."name" = 'nibc'
and "n"."identifier" = 1274
) or (
"t"."name" = 'client'
and "n"."identifier" = 383
))
it should work, no?
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"But as many as received him, to them gave he power to
become the sons of God, even to them that believe on
his name." John 1:12
From | Date | Subject | |
---|---|---|---|
Next Message | Casey Allen Shobe | 2003-04-17 11:43:06 | Re: Parethesis don't work correctly in where clause |
Previous Message | Casey Allen Shobe | 2003-04-17 08:23:05 | Parethesis don't work correctly in where clause |