SQL語句,當WHERE條件需要搜尋工號為16或工號為2的僱員姓名時,需用到OR關鍵詞如:
SELECT [EmployeeName] FROM [Employee] WHERE [WorkNumber] = 16 OR [WorkNumber] = 2
但是,上面SQL語句會涉及效率與效能問題,因為重寫上面SQL語句:
SELECT [EmployeeName] FROM [Employee] WHERE [WorkNumber] = 16
UNION ALL
SELECT [EmployeeName] FROM [Employee] WHERE [WorkNumber] = 2
UNION ALL
SELECT [EmployeeName] FROM [Employee] WHERE [WorkNumber] = 2