关系运算符:or、and的优先级问题

来源:互联网 发布:没有网站怎么做seo 编辑:程序博客网 时间:2024/06/05 13:38

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)


注意:

   在不确定执行顺序的时候,最好加上括号,括号的优先级最高,可读性也强





0 0