Oracle (8) ------- set operation

Source: Internet
Author: User

Set Operators

Union/unionall ------------- Union

The Union operator returns all records after two sets are removed from duplicated elements.

Union all returns all records of two sets, including duplicate
Select * from EMP where deptno = 20 and job = 'click'
Union
Select * from EMP where deptno = 10 and job = 'manager'

Intersect ------------- Intersection

The Intersect operator returns records that belong to both sets.

Minus ---------------- difference set

Minus returns a record that belongs to the first set but does not belong to the second set.

NOTE: If AB is regarded as a whole, the difference set between A and B can be considered as a complementary set of B in the AB range. [premise: A and B are two circles with overlapping parts]

Considerations for set operations:

L in the SELECT statement, the parameter types and numbers must be consistent.

L use parentheses to change the sequence of execution of the set.

L The set operation uses the header of the first statement as the header.

L The order by clause can only appear in the last one. The column, name, or alias accepted by the first select statement must be the same as the column name of the first select statement.

 

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.