select * from table_a where c1=v1 or c2=v2 and c3=v3;
在Mysql数据库中先执行and,再执行or,如果先要执行or需要用括号括起来,如下:
select * from table_a where (c1=v1 or c2=v3) and c3=v3
本文介绍了在Mysql数据库中执行查询语句时,如何通过调整AND与OR操作符的顺序来改变查询逻辑。通常情况下,数据库会先执行AND条件再执行OR条件,如果希望先执行OR条件,则需要使用括号明确指定。
select * from table_a where c1=v1 or c2=v2 and c3=v3;
在Mysql数据库中先执行and,再执行or,如果先要执行or需要用括号括起来,如下:
select * from table_a where (c1=v1 or c2=v3) and c3=v3
3868

被折叠的 条评论
为什么被折叠?