Fala Fala - 4 months ago 23
MySQL Question

How to correctly use left join in SQL

I'm writing an SQL select query that would retrieve all the names of students that are registered in a course that includes the word "Development" in the couse_name field.

I'm newbie here, and here's my SQL code:

select firstname, lastname
FROM students INNER JOIN registrations
ON students.student_id = registrations.student_id
and course_name = registrations.course_name LIKE '%Development%';


It is wrong I know, I want to know how to use left join correctly in order to retrieve valid data.
I've attached some screenshots for the tables.

Students Table:

Students Table

Courses Table:

enter image description here

Registrations Table:

enter image description here

Answer Source

Use this query

select students .firstname, students.lastname
FROM students INNER JOIN registrations
ON students.student_id = registrations.student_id
inner join courses on courses.course_code=registrations.course_code
where course.course_name LIKE '%Development%';