SQL中IN方法的使用

更新时间:2023-07-25 21:33:02 阅读: 评论:0

SQL中IN⽅法的使⽤
SQL: "IN" Function
The IN function helps reduce the need to u multiple OR conditions.
译:IN函数有助于减少OR条件的复合使⽤。
The syntax for the IN function is:
译:IN函数的语法:
SELECT columns
FROM tables
WHERE column1 in (value1, value2, .... value_n);
This SQL statement will return the records where column1 is value1, , or value_n. The IN function can be ud in any va
译:该SQL语句将返回column1的值是value1, , 或者value_n的记录。IN函数可以⽤于任何合法的SQL语句中-省会英文
lect, inrt, update, or delete。
Example #1manabe
The following is an SQL statement that us the IN function:
balla译:下⾯是⼀个使⽤IN函数的SQL语句
SELECT *
走遍法国FROM supplier
WHERE supplier_name in ( 'IBM', 'Hewlett Packard', 'Microsoft');
This would return all rows where the supplier_name is either IBM, Hewlett Packard, or Microsoft. Becau the * is ud in the
译:这将返回supplier_name为IBM, Hewlett Packard, 或者 Microsoft的所有记录。因为在SELECT中使⽤了*,supplier表中所有的字
段都会显⽰在结果集中。
It is equivalent to the following statement:
译:与下⾯的SQL语句相同:
SELECT *
FROM supplier
WHERE supplier_name = 'IBM'
OR supplier_name = 'Hewlett Packard'暧昧的英文
take your markOR supplier_name = 'Microsoft';
As you can e, using the IN function makes the statement easier to read and more efficient.
译:正如你所看到的,使⽤IN函数使语句更容易读并且有更⾼的执⾏效率。
different是什么意思
Example #2
You can also u the IN function with numeric values.
钱英文译:你也可以同数字使⽤IN函数
SELECT *
FROM orders
WHERE order_id in (10000, 10001, 10003, 10005);
This SQL statement would return all orders where the order_id is either 10000, 10001, 10003, or 10005.
译:将返回所有order_id是10000, 10001, 10003, 或者10005的记录
It is equivalent to the following statement:
译:与下⾯的SQL语句相同:
SELECT *
FROM orders
WHERE order_id = 10000
OR order_id = 10001
OR order_id = 10003
OR order_id = 10005;udi
Example #3 - "NOT IN"
The IN function can also be combined with the NOT operator.
译:IN函数可以和NOT操作符连⽤
For example,
SELECT *
FROM supplier
WHERE supplier_name not in ( 'IBM', 'Hewlett Packard', 'Microsoft');
This would return all rows where the supplier_name is neither IBM, Hewlett Packard, or Microsoft. Sometimes, it is more efficie
dier weg译:这将返回supplier_name不是IBM, Hewlett Packard,及Microsoft的所有记录。有时,与你想要的数据相反,这样可以更有效的例出
你不需要的值。

本文发布于:2023-07-25 21:33:02,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/188652.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:函数   语句   条件   减少   相反   走遍   集中
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图