Oracle any, some, all usage

Source: Internet
Author: User

I seldom use any, some, and all in my daily work. Today I suddenly see this usage, which is very good and should be used in my work;

 

Use some, any, and all to process the multiple rows returned by the subquery.

Next we will briefly introduce the meanings of these keywords.

* Some indicates that it satisfies one of the meanings. It is a comparative clause in the or string.

* Any also indicates satisfying the meaning of one of them. It is also a comparative clause concatenated with or. The difference is that any is generally used in a non-"=" comparative relationship, which is also easy to understand, the negative sentences in English use some in any statement, which is the same.

* "All" indicates that all of the query results meet the meaning of the query results, and the comparative clause in and string is used.

 

 

Any

Nested queries with [any] are the same as those with [some. Early SQL only allowed the use of [any]. Later versions introduced [some] to distinguish it from [any] in English, and reserved the [any] keyword.

Any:

Select EMP. empno, EMP. ename, EMP. Job, EMP. Sal from Scott. EMP where SAL> Any (select Sal from Scott. EMP where job = 'manager ');

The Query Process with any is equivalent to the execution process in two steps.

(1) Run "select Sal from Scott. EMP where job = 'manager '"

Select EMP. empno, EMP. ename, EMP. Job, EMP. Sal from Scott. EMP where SAL> 2975 or SAL> 2850;

 

Some

Some:

Select EMP. empno, EMP. ename, EMP. Job, EMP. Sal from Scott. EMP where sal = some (select Sal from Scott. EMP where job = 'manager ');

 

The nested query with some is the same as that of any.

(1) Run "select Sal from Scott. EMP where job = 'manager'" in the subquery. The result is 4.22.

(2) The parent query executes the following statements.

―――――――――――――――――――――――――――――――――――――

Select EMP. empno, EMP. ename, EMP. Job, EMP. Sal from Scott. EMP where sal = 2975 or sal = 2850 or sal = 2450;

 

All

 

All indicates query or subquery.

For example:

 

Select name from Edit

All is omitted before name.

You can add all | distinct before name.

All is all records.

Distinct is unique.

 

Select EMP. empno, EMP. ename, EMP. Job, EMP. Sal from Scott. EMP where SAL> All (select Sal from Scott. EMP where job = 'manager ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.