SQL IN 操作符
作者:会飞的
IN 操作符IN 操作符允许我们在 WHERE 子句中规定多个值。SQL IN 语法SELECTcolumn_name(s)FROMtable_nameWHEREcolumn_nameIN(value1,value2,...)原始的表 (在实例中使用:)Persons 表:IdLastNameFirstNameAddressCity1AdamsJohnOxford StreetLondon2BushGeorgeFifth AvenueNew York3CarterThomas
IN 操作符
IN 操作符允许我们在 WHERE 子句中规定多个值。
SQL IN 语法
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...)
原始的表 (在实例中使用:)
Persons 表:
Id | LastName | FirstName | Address | City |
---|---|---|---|---|
1 | Adams | John | Oxford Street | London |
2 | Bush | George | Fifth Avenue | New York |
3 | Carter | Thomas | Changan Street | Beijing |
IN 操作符实例
现在,我们希望从上表中选取姓氏为 Adams 和 Carter 的人:
我们可以使用下面的 SELECT 语句:
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 |
猜你喜欢
您可能感兴趣的文章:
- 使用Apache的rewrite技术
- python r.hgetall获取所有值
- Unexpected character (< (code 60)): expected a valid value (number, String, array, object, true, false or null)
- Linux性能命令
- phpstorm requisted without authorization
- The following untracked working tree files would be overwritten by checkout
- SQL 简介
- SQL 语法
- SQL SELECT 语句
- SQL SELECT DISTINCT 语句
- SQL WHERE 子句
- SQL AND & OR 运算符
- SQL ORDER BY 子句
- SQL INSERT INTO 语句
- SQL UPDATE 语句
- SQL DELETE 语句
- SQL TOP 子句
- SQL LIKE 操作符
- SQL 通配符