Home >Database >Mysql Tutorial >What are MySql self-join, outer join, inner join, left join and right join?
In the final analysis, multiple tables are data restricted by adding certain conditions to the same table. This is simple to understand. Why use "where a.age = a.num;" in such a complicated way? .
Outer join includes left join and right join. Just look at the left join and right join
To put it simply, no matter what the final result is, the table on the left is all displayed, and the table on the right is displayed according to the conditions
No need for my introduction. In fact, it is that simple and does not need to be complicated to understand.
--创建 stu这个表格 CREATE TABLE `stu_name` ( `id` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 --创建stu_score CREATE TABLE `stu_name` ( `id` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8
Insert data:
From the screenshot above, we can see that all the data in the table on the left is displayed, and the data in the table on the right is displayed based on conditions.
We can also know from the above picture that actually all the tables on the right are displayed, but not all the coordinate tables Displayed
It can be seen from here that the same table is actually operated here, that is, self-join
The so-called internal connection is to display the same parts, and delete the other ones that do not meet the conditions!
The above is the detailed content of What are MySql self-join, outer join, inner join, left join and right join?. For more information, please follow other related articles on the PHP Chinese website!