[Solved] First time to query 3 mysql tables [closed]


You have to use 2 joins to link these 3 tables.
INNER JOIN means, that only those tuples are listed, for which an correct tuple exists in every table. Students without subjects or wrong subject_ids will not be listed.

Keep in mind, that an student, which visits X subjects will also listed X times.

SELECT n.student_id, n.student_name, s.subject_name, s.description FROM student_name n INNER JOIN student_has_subjects shs ON shs.stud_name = n.student_name INNER JOIN subjects s ON shs.stud_subject = s.subject_id

If it is an homework of you, please mark it as one!

1

solved First time to query 3 mysql tables [closed]