在 SQL 中,在两个情况下会用到 IN 这个指令;这一页将介绍其中之一━━与 WHERE 有关的那一个情况。在这个用法下, 我们事先已知道至少一个我们需要的值,而我们将这些知道的值都放入 IN 这个子句。 IN 指令的语法为下:
SELECT "栏位名"
FROM "表格名"
WHERE "栏位名" IN ('值一', '值二', ...)
在括弧内可以有一或多个值,而不同值之间由逗点分开。值可以是数目或是文字。 若在括弧内只有一个值,那这个子句就等于
WHERE "栏位名" = '值一'
举例来说,若我们要在 Store_Information 表格中找出所有含盖 Los Angeles 或 San Diego 的资料,
Store_Information 表格
store_name |
Sales |
Date |
Los Angeles |
$1500 |
Jan-05-1999 |
San Diego |
$250 |
Jan-07-1999 |
San Francisco |
$300 |
Jan-08-1999 |
Boston |
$700 |
Jan-08-1999 |
我们就打入,
SELECT *
FROM Store_Information
WHERE store_name IN ('Los Angeles', 'San Diego')
结果:
store_name |
Sales |
Date |
Los Angeles |
$1500 |
Jan-05-1999 |
San Diego |
$250 |
Jan-07-1999 |
分享到:
相关推荐
Sams Teach Yourself SQL in 10 Minutes has established itself as the gold standard for introductory SQL books, offering a fast-paced accessible tutorial to the major themes and techniques involved in ...
Teach Yourself SQL in 21 Days
teach yourself SQL in 24 hours
Sams Teach Yourself SQL in 10 Minutes has established itself as the gold standard for introductory SQL books, offering a fast-paced accessible tutorial to the major themes and techniques involved in ...
SQL in a Nutshell讲述sql的基础知识,可能对大家有帮助。
SQL 必知必会 第4版 英文原版 SQL in 10 Minutes , Sams Teach Yourself 4th Edition 第四版 仅分享阅读 非版权所有
是Sql in 21 days填的电子版本,值得初学者看,英文版
Sql in split Sql in split Sql in split Sql in split
Sams Teach Yourself SQL in 10 Minutes
Sams Teach Yourself SQL in 24 Hours(5th) 英文无水印原版pdf 第5版 pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除...
Teach yourself SQL in 21 days.pdf
POWERBLUIDE11 将带有分隔符的字符串,转为SQL IN语句中需要的格式字符串;如:ABCD1234,ABCD5678 转换为 'ABCD1234','ABCD5678'然后可放直接放入IN语句中。
Teach Yourself SQL in 10 Minutes的实例源码 从书提供的网站上down的
Since its first incarnation in the 1970s, Structured Query Language (SQL) has been developed hand in hand with the information boom, and as a result, is the most widely used database manipulation ...
[数据库]处理 Oracle SQL in 超过1000 的解决方案.txt
Sams Teach Yourself SQL in 24 Hours(6th) 英文无水印转化版pdf 第6版 pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn...
里面自己根据网上的资源整理出来的一份sql中in,exists,not in,not exists的使用方法以及注意事项等,有助于初学的朋友们借鉴。
工作需要,拼接字符串头晕眼花拼接的,特别是in 查询,后面的参数太多,想在数据执行一些这个sql语句老费劲了,所以写了一个生产in后面参数的字符串小工具
oracle sq 使用l in 连接大于1000情况下报错解决办法。