zhiqingstudy

Be a young person with knowledge and content

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:

What is the SQL left connection query statement and the database left connection query statement

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:

What is the SQL left connection query statement and the database left connection query statement

comment
head sculpture
Code:
Related

Why you shouldn't stay at a job for more than 2 years?

3 harsh facts long-distance relationships

how to keep your girlfriend interested in a long-distance relationship




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号