SQL table connection

Source: Internet
Author: User

SQL table connection

Background

In the last self-study subject database system principles, I have gained some knowledge about database table connections. Recently, I used database table connections, let's take a look at it again.

Graph export Summary

First, use a mind map to summarize the content of SQL table join:

After having a rough understanding of SQL table join, let's take a further look at it through a small example. First, I create two tables:

External Connection

External connections include left outer connections, right outer connections, and full outer connections.

Left Outer Join

SQL statement: select * from table1 left join table2 on table1.id = table2.id

Outer right connection

SQL statement: select * from table1 right join table2 on table1.id = table2.id

Complete connection

SQL statement: select * from table1 full join table2 on table1.id = table2.id

Internal Connection

SQL statement: select table1.id, table2.score from table1 inner join table2 on table1.id = table2.id

Cross join

SQL statement: select * from table1 cross join table2 on table1.id = table2.id

In fact, learning is like this. At the same time, through review, each time there will be different gains, a little deeper understanding.

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.