Does the SQL query
SELECT * FROM table_a where cond1 or cond2 and cond3;
deliver the same result as
SELECT * FROM table_a where (cond1 or cond2) and cond3;
?
No. Boolean operators have precedence rules -- in all programming languages that use them and in mathematics before that. "AND" binds more closely than "OR". This is analogous to arithmetic operators.
Just as:
1 + 2 * 3
is different from:
(1 + 2) * 3
Your two versions are different. AND
binds more tightly (like *
). OR
less tightly (like +
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.