and的优先级大于or
如:
①select * from tablename where condition1 or condition2 and condition3
其实相当于
select * from tablename where condition1 or (condition2 and condition3)
②select * from tablename where condition1 and condition 2 or condition3 and condition4
其实相当于
select * from tablename where (condition1 and condition 2) or (condition3 and condition4)
注意:
在不确定执行顺序的时候,最好加上括号,括号的优先级最高,可读性也强