A concise tutorial on SQL statements in linux --- UNION ALL, a concise tutorial --- union

Source: Internet
Author: User

A concise tutorial on SQL statements in linux --- UNION ALL, a concise tutorial --- union

UNION ALLThe purpose of this command is to combine the results of two SQL statements.UNION ALLAndUNIONThe difference is thatUNION ALLEach qualified item is listed, regardless of whether the item value is repeated.

UNION ALLSyntax:

[SQL statement 1]
UNION ALL
[SQL statement 2];

We use the same example on the previous page to showUNION ALLAndUNION. Let's assume that we have the following two tables,

Store_InformationTable

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 SalesTable

Txn_Date Sales
07-Jan-1999 250
10-Jan 1999 535
11-Jan 1999 320
12-Jan 1999 750

However, we need to find out the days when there are store turnover and network turnover. To achieve this goal, we use the following SQL statement:

SELECT Txn_Date FROM Store_Information
UNION ALL
SELECT Txn_Date FROM Internet_Sales;

Result:

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 has been tested as follows:




Reprinted, please note: Xiao Liu

Bytes

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.