The difference between the inner join, the left join, and the right join in SQL

Source: Internet
Author: User

Here's a look at the difference between the inner join, the left JOIN, the right Join

Now I'm assuming there's A and B tables.

Left Join

SELECT * from a a left joins b b on a.aid = B.bid;

At this point on the left of a table as the base table, a table of data are all displayed, B table of data only shows the display of the conditional expression matching on, the right field data is insufficient to fill with null

Right Join

SELECT * from a a right joins b b on a.aid = B.bid;

At this point, the right side of table B is the base table, the data of table B is all displayed, the data of a table only shows the display of the conditional expression according to the on, the left field data is insufficient to fill with null

INNER JOIN

SELECT * from a a inner joins b b on a.aid = B.bid;

When querying using the inner join, only the data that matches the on expression can be displayed, that is, only the data in the two tables is displayed, the data contained in the single table is not displayed, so null is not present in the table queried when using the inner join.

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.