SQL Server和或

SQL Server和或,sql,sql-server,Sql,Sql Server,愚蠢的问题,但两者之间有区别吗 Select * from TableA where System=1 and Acct=2 and FiscalNo=4 or System=2 and FiscalNo=4 and SubAcct=1521 及 请注意,区别在于括号 由于SQL语句中的操作顺序,第一个查询没有括号。由于SQL语句中的操作顺序,它仍然会优先于或。。它仍将优先于或。和绑定的优先级高于或。因此,没有区别 不过,为了清晰起见,请使用样式2。这就省去了这个问题。和绑定的优先级高于或。

愚蠢的问题,但两者之间有区别吗

Select * from TableA
where 
System=1 and Acct=2 and FiscalNo=4
or
System=2 and FiscalNo=4 and SubAcct=1521

请注意,区别在于括号
由于SQL语句中的操作顺序,第一个查询没有括号。由于SQL语句中的操作顺序,它仍然会优先于或。

。它仍将优先于或。

绑定的优先级高于
。因此,没有区别


不过,为了清晰起见,请使用样式2。这就省去了这个问题。

绑定的优先级高于
。因此,没有区别


不过,为了清晰起见,请使用样式2。这就省去了这个问题。

除了易读,没有其他区别。除了易读,没有其他区别。
Select * from TableA
where 
(System=1 and Acct=2 and FiscalNo=4)
or
(System=2 and FiscalNo=4 and SubAcct=1521)