You need to use aliases + RIGHT JOIN, which means: get all records from
csr_courses
and matching data from
std_details
:
SELECT sd.StudentID, sd.FirstName, sd.LastName, sd.CGPA
FROM std_details sd RIGHT JOIN csr_courses cc ON sd.StudentID = cc.StudentID
WHERE cc.Course_1 = 'PHIL340' OR cc.Course_2 = 'PHIL340' OR cc.Course_3 = 'PHIL340' OR cc.Course_4 = 'PHIL340' OR cc.Course_5 = 'PHIL340'
For further information, please see:
Visual Representation of SQL Joins[
^]
MySQL JOIN[
^]
By The Way: Are you sure that
csr_courses
contains searched data in
Course_x
field?