select count(*) from TestTable
==>输出 10
select count(*) from TestTable where 1=2
==>输出 0
select count(*) from TestTable where 1=2 or 1>0
==>输出 10
select count(*) from TestTable where 1=2 or 1>0 and 2=3
==>输出 0
为什么第4条语句输入是0条记录?
------解决方案--------------------
因为这样的写法就等于下面的
select count(*) from TestTable where 1=2 or (1>0 and 2=3)
这样看楼主肯定就明白了, or左右两边的条件都部满足
------解决方案--------------------
多个常量的比较规则是这样的:
先无次序的把所有连续的and比较完,然后再无次序的把所有or比较完。
比如
b1 or b2 and b3 and b4 or b5 and b6 or b7
先会生成:
b1 or b234 or b56 or b7
然后生成
b1234567
------解决方案--------------------
计算优先级别是:括号, not , and , or .
------解决方案--------------------
优先级参考 http://technet.microsoft.com/zh-cn/library/ms190276.aspx
and 比 Or 要 优先 。