用于在 WHERE 子句中 规定多个值 。
语法
SELECT 列 FROM 表 WHERE 列 IN (value1,value2,...)
表:
Id |
LastName |
FirstName |
Address |
City |
1 |
Adams |
John |
Oxford Street |
London |
2 |
Bush |
George |
Fifth Avenue |
New York |
3 |
Carter |
Thomas |
Changan Street |
Beijing |
例
如果我们希望从表中选取 姓氏为 Adams 和 Carter 的人:
SELECT * FROM Persons
WHERE LastName IN ('Adams','Carter')
结果:
Id |
LastName |
FirstName |
Address |
City |
1 |
Adams |
John |
Oxford Street |
London |
3 |
Carter |
Thomas |
Changan Street |
Beijing |