In-depth description of SQL SERVER merge operations such as Union, Except T, and Intersect

Source: Internet
Author: User

There are several processing methods for the result set, which are worth explaining.
1. union (Union, union all)
This is simple. It combines two result sets horizontally. For example
SELECT * FROM
UNION
SELECT * FROM B
[Note] union deletes duplicate values. That is to say, duplicate rows in A and B will only appear once, while union all will keep duplicate rows.

2. Variance t)
It is the unique part of the two sets. For example
SELECT * FROM
EXCEPT
SELECT * FROM B
This means that no row exists in Table A of table B.


3. Intersection (intersect)
Is the common part of the two sets. For example
SELECT * FROM
INTERSECT
SELECT * FROM B
This means that records appear in both A and B

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.