Oracle set Operators

Source: Internet
Author: User

[SQL]
<Span style = "font-size: 18px;"> </span>
[SQL]
<Span style = "font-size: 18px;"> set operator: UNION/union all union set, INTERSECT intersection, MINUS difference set
 
1. union is used to calculate the union. The public part only contains one
For example, find that the name of the emp table contains 'A' or 'M'
SQL> select * from emp where ename like '% A %'
2 union
3 select * from emp where ename like '% M % ';
 
2. union all calculates the union, and the public part only contains the secondary
For example, find that the name of the emp table contains 'A' or 'M'
SQL> select * from emp where ename like '% A %'
2 union all
3 select * from emp where ename like '% M % ';
 
3. Intersection of intersect values, including only the public part
For example, find that the name of the emp table contains 'A' and 'M'
SQL> select * from emp where ename like '% A %'
Intersect
Select * from emp where ename like '% M % ';
 
4. minus calculates the difference set and obtains set A to remove the intersection of set A and Set B.
Example: Evaluate the emp table sal from 700 to 1200
SQL> select * from emp where sal between 700 and 1300
Minus
Select * from emp where sal between 1200 and 1400;
 
</Span>



From song lixing's column

Related Article

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.