Drill down to SQL Server merge related operations Union,except,intersect detailed _mssql

Source: Internet
Author: User
There are several treatments for the result set that are worth explaining
1. and set (Union,union all)
This is very simple, is to combine two result set level. For example
SELECT * from A
UNION
SELECT * from B
Note Union deletes duplicate values, that is, duplicate rows in a and B end up only once, while union all retains duplicate rows.

2. Variance (Except)
is a two-part set that does not repeat. For example
SELECT * from A
EXCEPT
SELECT * from B
This means that the rows of a table that do not appear in table B.


3. Intersection (INTERSECT)
is a common part of two. For example
SELECT * from A
INTERSECT
SELECT * from B
This means that the records that 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.