题目
A表字段a 类型int中有100条记录,值分别为1至100。如下语句SELECT a FROM A WHERE a BETWEEN 1 AND 50 OR (a IN (25,70,95) AND a BETWEEN 25 AND 75) 则如下哪个值在这个sql语句返回的结果集中?
A.30
B.51
C.75
D.95
A表字段a 类型int中有100条记录,值分别为1至100。如下语句SELECT a FROM A WHERE a BETWEEN 1 AND 50 OR (a IN (25,70,95) AND a BETWEEN 25 AND 75) 则如下哪个值在这个sql语句返回的结果集中?
A.30
B.51
C.75
D.95
这个问题很常见
WHERE a BETWEEN 1 AND 50 OR (a IN (25,70,95) AND a BETWEEN 25 AND 75) 的意思是a的范围为(1-50)|((25,70,95)&(25-75)所以只要第一项(1-50)满足就好了
优先级 AND 大于 OR