1SELECT students.name, students.lastname, ifnull(courses.course_name, '-') as course_name
2FROM students
3LEFT JOIN courses
4ON courses.id_student=students.id_student
5WHERE students.name LIKE '%$search%'
6GROUP BY students.id_student
7ORDER BY students.name, students.lastname, courses.course_name
8