No parens in where clause

No parens in where clause

am 12.05.2006 02:13:02 von Ike

I cannot find now, what the precedence is in the where clause of a select
statement, where "AND" and "OR" are mixed in, and there are no parentheses.

For example:

WHERE a=1 and b=2 or c=3

How would that be "parenthesized" internally in MySQL? What is the rule for
precedence between and and or? Thanks IKe

Re: No parens in where clause

am 12.05.2006 02:20:19 von Bill Karwin

Ike wrote:
> WHERE a=1 and b=2 or c=3
>
> What is the rule for precedence between and and or?

AND has higher precedence than OR.

E.g.:

WHERE (a=1 AND b=2) OR c=3

FWIW, this is the same boolean operator precedence as in virtually any
other programming language you care to mention.

See also http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.h tml

Regards,
Bill K.