Databases are rarely used, and only simple addition, deletion, selection, and modification are allowed. A few days ago, during the interview, I was asked to connect left and right, and then... then there was no more.
I searched some materials online and tried it again. I finally understood it. It is recorded here for future reference.
For more information, see the example.
Below are two tables
Table stu
Table tech
1. Right join
When the right join statement is used for query, the following result is returned:
stu.id,stu.name,stu.classe_name,tech.id,tech.name stu tech stu.classe_nametech.classe_name;
From the results, we can see that all the fields queried in the tech table will be displayed, while in the stu table, only the corresponding fields of the same entries as the classe_name of the tech table will be displayed.
stu.id,stu.name,stu.classe_name,tech.id,tech.name stu tech stu.classe_nametech.classe_name;
It can be seen from the results that all the queried fields in the stu table will be displayed, while in the tech table, only the corresponding fields of the same entry as the classe_name of the stu table will be displayed.
Left join: return all queried fields in the left table + qualified fields in the right table.
3. Internal Connection
When an internal connection statement is used for query, the following results are returned:
stu.id,stu.name,stu.classe_name,tech.id,tech.name stu tech stu.classe_nametech.classe_name;
From the results, we can see that entries with the same classe_name in the stu and tech tables are displayed.