SQL full left right inner cross Basics

Source: Internet
Author: User
Let's give a simple example. The results are more specific.
Table
Name sex
Michael Zhang
4 female Li

Table B
Name age
Li Si 30
Wang Wu 23

1 \ All external connections
Select a. Name, A. Sex, B. Name, B. Age
From a full outer join B on A. Name = B. Name
The result is as follows,
Name sex name age
John's male is null
Li Si female Li Si 30
Null null Wang Wu 23
Name of the joined field, which exists in the left table but not in the right table, for example, John and B. name, B. the age values are null, and the left and right sides are the result of the left join. The right table does not exist in the left table, for example, Wang Wu,. name,. the sex is null, and both sides are the result of the right connection; both sides are, for example, Li Si, which is the internal connection. See the following
2 \ left
Select a. Name, A. Sex, B. Name, B. Age
From a left Outer Join B on A. Name = B. Name
The result is as follows:
Name sex name age
John's male is null
Li Si female Li Si 30
2 \ Right
Select a. Name, A. Sex, B. Name, B. Age
From a right Outer Join B on A. Name = B. Name
The result is as follows:
Name sex name age
Li Si female Li Si 30
Null null Wang Wu 23
3 \ inline
Select a. Name, A. Sex, B. Name, B. Age
From a inner join B on A. Name = B. Name
The result is as follows:
Name sex name age
Li Si female Li Si 30
4 \ crossover
Select a. Name, A. Sex, B. Name, B. Age
From a cross join B on A. Name = B. Name
The result is as follows:
Name sex name age
Zhang San male, Li Si 30
Li Si female Wang Wu 23
Zhang San male Wang Wu 23
Li Si female Li Si 30

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.