Linux SQL statement Concise tutorial---UNION all

Source: Internet
Author: User

The purpose of the UNION all directive is to merge the results of the two SQL statements together. the union All and union differ in that union all lists each qualifying material, regardless of whether the data value is duplicated or not.

The syntax for UNION All is as follows:

[SQL Statement 1]
UNION All
[SQL statement 2];

We use the same example as the previous page to show the difference between union All and union . Also assume that we have the following two tables,

store_information Form

Store_name Sales Txn_date
Los Angeles 1500 05-jan-1999
San Diego 250 07-jan-1999
Los Angeles 300 08-jan-1999
Boston 700 08-jan-1999

Internet Sales table

Txn_date Sales
07-jan-1999 250
10-jan-1999 33s
11-jan-1999 320
12-jan-1999 750

And we need to find out the days of store turnover and network turnover. To achieve this, we use the following SQL statement:

SELECT txn_date from Store_information
UNION All
SELECT txn_date from Internet_sales;

Results:

Txn_date
jan-05-1999
jan-07-1999
jan-08-1999
jan-08-1999
jan-07-1999
jan-10-1999
jan-11-1999
jan-12-1999



Linux is measured as follows:




Reprint please specify: Xiao Liu



Linux SQL statement Concise tutorial---UNION all

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.