SQL逻辑操作符优先性:和或以下两项声明是否相等?SELECT [...]FROM [...]WHERE some_col in (1,2,3,4,5) AND some_other_expr和SELECT [...]FROM [...]WHERE some_col in (1,2,3) or some_col in (4,5) AND some_other_expr我能用什么真值表来证实这一点吗?
3 回答
守着星空守着你
TA贡献1799条经验 获得超8个赞
And
Or
a <=> a1 Or a2
Where a And b
Where a1 Or a2 And b,
Where a1 Or (a2 And b)
Where (a1 Or a2) And b
Declare @x tinyInt = 1Declare @y tinyInt = 0Declare @z tinyInt = 0Select Case When @x=1 OR @y=1 And @z=1 Then 'T' Else 'F' End -- outputs TSelect Case When (@x=1 OR @y=1) And @z=1 Then 'T' Else 'F' End -- outputs F
繁花如伊
TA贡献2012条经验 获得超12个赞
“IN”实际上是带有括号的串行OR。 在我所知道的每一种语言中都优先于OR
WHERE some_col in (1,2,3,4,5) AND some_other_expr--to the optimiser is thisWHERE ( some_col = 1 OR some_col = 2 OR some_col = 3 OR some_col = 4 OR some_col = 5 ) AND some_other_expr
添加回答
举报
0/150
提交
取消