📜  从 1 个表中获取行,其他表为空 mysql 代码示例

📅  最后修改于: 2022-03-11 15:05:28.744000             🧑  作者: Mango

代码示例1
SELECT students.name, students.lastname, ifnull(courses.course_name, '-') as course_name
FROM students
LEFT JOIN courses
ON courses.id_student=students.id_student 
WHERE students.name LIKE '%$search%'
GROUP BY students.id_student 
ORDER BY students.name, students.lastname, courses.course_name