Left join query
Use the left table as the criteria to query the data in the right table. If the right table data does not exist according to the criteria, fill it with null values.
Effect picture of left connection query:
Left join query syntax format:
SELECT 字段 FROM 表1 LEFT JOIN 表2 on 表1.字段1= 表2.字段2 ;
explain:
① , LEFT JOIN is the query keyword of the left connection;
② And on are connection query criteria;
③ Table 1 is the left table;
④ Table 2 is the right table.
Example: Use the left join to query the student table and class table
SELECT * FROM `students` LEFT JOIN `class` on students.class= class.`className` ;
The execution results are shown in the figure below: