Oracle中In函数的使用

news/2024/7/6 1:15:56
               

SQL: "IN" Function

The IN function helps reduce the need to use 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, value2..., or value_n. The IN function can be used in any valid SQL statement - select, insert, update, or delete.

译:该SQL语句将返回column1的值是value1, value2..., 或者value_n的记录。IN函数可以用于任何合法的SQL语句中-select, insert, update, or delete。

Example #1

The following is an SQL statement that uses the IN function:

译:下面是一个使用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. Because the * is used in the select, all fields from the supplier table would appear in the result set.

译:这将返回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'
OR supplier_name = 'Microsoft';

As you can see, using the IN function makes the statement easier to read and more efficient.

译:正如你所看到的,使用IN函数使语句更容易读并且有更高的执行效率。

Example #2

You can also use 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;

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 efficient to list the values that you do not want, as opposed to the values that you do want.

译:这将返回supplier_name不是IBM, Hewlett Packard,及Microsoft的所有记录。有时,与你想要的数据相反,这样可以更有效的例出你不需要的值。

如果文章对你用,请支持万事如意网址导航。

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow


http://www.niftyadmin.cn/n/3301286.html

相关文章

再学 GDI+文本输出文本样式

代码文件: unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, CheckLst;typeTForm1 class(TForm)CheckListBox1: TCheckListBox;procedure FormPaint(Sender: TObject);procedure FormCreate(Sender: T…

WordPress实现中英文数字之间自动加空格排版

通常来说中文与英文、中文和数字之间加上空格的排版会更加好看,但是如果让我们在编辑文章的时候人工添加,感觉非常繁琐和让人厌烦,所以今天龙笑天下就来跟大家介绍一下WordPress如何实现中英文数字之间自动加空格的排版技巧。(PS&…

[Elasticsearch] 控制相关度 (五) - function_score查询及field_value_factor,boost_mode,max_

本章翻译自Elasticsearch官方指南的Controlling Relevance一章。 function_score查询 function_score查询是处理分值计算过程的终极工具。它让你能够对所有匹配了主查询的每份文档调用一个函数来调整甚至是完全替换原来的_score。 实际上,你可以通过设置过滤器来将查…

Delphi利用Windows GDI实现文字倾斜

Delphi利用Windows GDI实现文字倾斜摘要 Delphi利用Windows GDI实现文字倾斜procedure TForm1.FormPaint(Sender: TObject);var FLogFont: tagLogFontW; hTempFont, hPrevFont: HFONT; //字体句柄 hTempDC: HDC; //设备描述表或图形设备句柄 TempString: string; //输出的文…

CodeForces 631 A.Interview(水~)

Description f(x,l,r)表示将x序列的第l个元素到第r个元素按位或后的结果&#xff0c;给出两个长度为n的序列&#xff0c;问f(a,l,r)f(b,l,r)的最大值&#xff0c;1<l<r<n Input 第一行一整数n表示序列长度&#xff0c;之后输入两个长度为n的序列a和b(0<ai,bi<…

Python学习笔记(一)——输入与输出

输出&#xff1a;——print() Python中的输出使用print()完成 >>> 在屏幕中输出Hello World >>> print(Hello World) Hello World使用print()函数输出多个字符串时要使用逗号隔开 >>> print(hello,everyone,this,is,GUN) hello everyone this is GU…

ElasticSearch中设置排序Java

有用的链接:http://stackoverflow.com/questions/12215380/sorting-on-several-fields-in-elasticsearch 有的时候,需要自己设定排序,java的一个接口如下: String time1 ConstValue.GetCurrentDate();SortBuilder sortBuilder SortBuilders.fieldSort("tfp_save_time&qu…

C++如何判断某一文件是否存在

函数名: access功 能: 确定文件的访问权限用 法: int access(const char *filename, int amode);程序例:#include <stdio.h>#include <io.h>int file_exists(char *filename);int main(void){printf("Does NOTEXIST.FIL exist: %s\n",file_exists("…