mysql and or not

来源:互联网 发布:二战德国有机会吗 知乎 编辑:程序博客网 时间:2024/06/05 17:31

select   *   from   table   where   Condition1   and   Condition2   or   Condition3

执行顺序为:select   *   from   table   where   (Condition1   and   Condition2)   or   Condition3 
先执行and搜索,在执行or过滤


要搜索表table中满足Condition1且满足Condition2和Conditon3中其中一个时候使用下面的语句

select   *   from   table   where   Condition1   and   (Condition2   or   Condition3) 搜索的是Condition1   且等于Condition2   或者Condition1   且等于Condition3 

优先级:not>and>or

0 0
原创粉丝点击