SQL Server:选择vs还是?

问题描述:

哪个更快?

SELECT UserName
FROM dbo.UserTable
WHERE UserID in (1,3,4)


SELECT UserName
FROM dbo.UserTable
WHERE UserID = 1 
      OR UserID = 3
      OR UserID = 4

由于Sql Server对查询的优化,由于它们在逻辑上是等效的,因此它们将以相同的速度运行.

Due to Sql Server's optimization of queries these will run at the same speed since they are logically equivalent.

尽管我出于简洁和可读性的考虑而赞成IN语法.

i favor the IN syntax for brevity and readability though.