【SQL语法】系列11:IN 操作符

用于在 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

你可能感兴趣的:(sql)