Basic SQL internal connection and external connection, basic SQL connection

Source: Internet
Author: User

Basic SQL internal connection and external connection, basic SQL connection

Some problems have been depressing for a long time. For example, why is there a connection between the left and right sides? If the foreign key is empty, the foreign key constraint will fail during statement creation.

Later, I carefully studied that the inner join and outer join (left join and right join) are created in a table with no primary or foreign key constraints.

In fact, they are all very basic things. I didn't understand it before. I spent some time organizing it today.

First select * from t_class


Then select * from t_student



1. inner connection

Inner join: You can use the inner join to obtain the records of the public parts of the two tables. That is, the C statement of the record set in Figure 3 is as follows: the execution result of Select * from t_class JOIN t_student ON t_class.id = t_student.belongClass_id is shown in Figure 4: It is the same as select * from t_student, t_class WHERE t_class.id = t_student.belongClass_id.

2. Outer connections are divided into left connections and right connections.

Left join (add t_student to the public part)

Right join (record of adding t_class to public part)


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.