Home >Database >Oracle >How to use in in oracle sql statement

How to use in in oracle sql statement

WBOY
WBOYOriginal
2022-06-20 16:36:225261browse

In Oracle, in in the sql statement is used to operate data within a certain range. The specified field value only needs to satisfy any one within this range. The syntax is "select * from table Name where field in (value1, value2,…);”.

How to use in in oracle sql statement

The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.

How to use in in Oracle's sql statement

In Oracle, in is often used in where conditional expressions. It can operate on data whose field values ​​meet the specified range. The syntax is " select * from table name where field in (value1, value2,…);”.

in is often used in conditional expressions (where). Its function is to operate, query or delete data within a certain range. The field value can be satisfied as long as it meets any one within this range

Query

select * from TableName(表名) where 字段 in (value1,value2,…);
select * from TableName(表名) where 字段 not in (value1,value2,…);
select 字段1,字段2,… from 表名 where 字段 in/not in (value1,value2,…);

Delete

delete from 表名 where 字段 in/not in (value1,value2,…);

The example is as follows:

in is used to query records

   (1) Query all records in the t_hero table

How to use in in oracle sql statement
   (2) Query keyid equal to (21,16,7) This All records with one of the three values ​​can be queried as long as they satisfy one of the three values.

How to use in in oracle sql statement
   (3) Query all records whose keyid is not in the range of (21,16,7).

How to use in in oracle sql statement

3.2 in is used to delete records

 (1) Query all records in the t_hero table, there are now 7 records
How to use in in oracle sql statement
 (2) Delete the two records with keyid = (14,15)
How to use in in oracle sql statement

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to use in in oracle sql statement. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn