One of the SQL Master tables records multiple record statements corresponding to the schedule

Source: Internet
Author: User
Tags join ming

One of the SQL Master tables records multiple record statements corresponding to the schedule

Like this, we use the

Union statement

SQL Union syntax

Select column_name (s) from table_name1
Union
Select COLUMN_NAME (s) from Table_name2


Join left statement

LEFT JOIN keyword syntax

Select column_name (s)
From table_name1
Left JOIN Table_name2
On Table_name1.column_name=table_name2.column_name


where child query

SELECT * from a b where a.id=b.id


Here, let's look at an example.

Select XXXX from main Table INNER join schedule on Main table. xxxx= schedule. xxxx where xxxx

Example Description.


Employees_china:
e_id E_name
Zhang, Hua
Wang, Wei
Carter, Thomas
Yang, Ming

Employees_usa:
e_id E_name
Adams, John
Bush, George
Carter, Thomas
Gates, Bill.

List all the different employee names in China and the United States:

Select E_name from Employees_china
Union
Select E_name from Employees_usa
Results
E_name
Zhang, Hua
Wang, Wei
Carter, Thomas.
Yang, Ming
Adams, John.
Bush, George.
Gates, Bill.

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.