MySQL语句之or/and

来源:互联网 发布:python游戏开发教程 编辑:程序博客网 时间:2024/06/05 20:16

在where中可以包含任意数目的and和or操作符,在没有任何其他符号的时候,例如括号,SQL会首先执行and条件,然后才执行or语句

eg.    select * from table from id=1 or id=2 and price>=10;

这条语句默认执行的是id=2并且price大于等于10的,或者是id=1。

如果加上括号:select * from table from (id=1 or id=2) and price>=10;

则这条语句执行的是id=1或id=2,并且price大于等于10。

2 2
原创粉丝点击