关系型运算符优先级高到低为:NOT >AND >OR
如果where 后面有OR条件的话,则OR自动会把左右的查询条件分开。
也就是说,在没有小括号()的干预下,总是先执行AND语句,再执行OR语句。
例:
select * from table where 条件1 AND 条件2 OR 条件3
等价于
select * from table where ( 条件1 AND 条件2 ) OR 条件3
select * from table where 条件1 AND 条件2 OR 条件3 AND 条件4
等价于
select * from table where ( 条件1 AND 条件2 ) OR ( 条件3 AND 条件4 )