问题
I'm debugging some code and came across this. Could someone help me by putting parens around this statement according to SQL Server ordering. Is it just me, or is this bad coding?
WHERE
T1.C1 = @VAR1 AND T1.C2 = @VAR2 AND T1.C3 NOT IN(@VAR3)
OR T2.C1 = @VAR2 OR T3.C1 = @VAR2
回答1:
As is, it will be parsed like
WHERE
(T1.C1 = @VAR1 AND T1.C2 = @VAR2 AND T1.C3 NOT IN(@VAR3))
OR
(T2.C1 = @VAR2)
OR
(T3.C1 = @VAR2)
来源:https://stackoverflow.com/questions/17094612/sql-server-ands-and-ors-precedence