Content related to left join and inner join

Source: Internet
Author: User

Left join is short for left Outer Join. Left join is outer by default.
Inner join
The inner join logical operator returns each row that matches the first (top) input and the second (bottom) Input join. This is the same effect as querying multiple tables using select statements, so it is rarely used;
Outer Join returns each row that matches the join of the first (top) input and the second (bottom) input. It also returns any rows in the first input without matching rows in the second input. The key is the following sentence, which returns more. In general, left join is left Outer Join.

I. Let's take a look at some of the simplest examples.

Example

Table
Aid adate
1 A1
2 A2
3 A3

Tableb

Bid bdate
1 B1
2 B2
4 B4
Two tables A and B are connected. fields with the same ID must be retrieved.
Select * fromInner joinB On A. Aid = B. Bid this is to retrieve only the matched data.
In this case, the following information is taken:
1 A1 B1
2 A2 B2

Then left join refers:
Select * fromLeft joinB On A. Aid = B. Bid
First, retrieve all the data in Table A, and then add the data that matches table A and table B.
In this case, the following information is taken:
1 A1 B1
2 A2 B2
3 A3 null characters

There are alsoRight join
This means that all data in Table B is retrieved first, and then the data matching A and B is added.
In this case, the following information is taken:
1 A1 B1
2 A2 B2
4 blank characters B4

Left join or left Outer Join.
The result set of the left Outer Join includes all rows in the left table specified in the left outer clause, not just the rows matched by the join column. If a row in the left table does not match a row in the right table, all the selected list columns in the right table in the row of the associated result set are null.

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.