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)