Right Join Query
Query the left table data based on the right table and criteria. If the left table data of the criteria query does not exist, fill it with null values.
Effect picture of right link query:
Right join query syntax format:
SELECT 字段 FROM 表1 RIGHT JOIN 表2 on 表1.字段1 =表2.字段2 ;
explain:
① Right JOIN is the right join query keyword;
② And on are connection query criteria;
③ Table 1 is the left table;
④ Table 2 is the right table.
Example: Use the right link to query the student table and class table
SELECT * FROM `students` RIGHT JOIN `class` on class.`className` =students.`class` ;
Execution result: