I have 3 tables
- students (id, name)
- student_class_relation (id, student_id, class_id)
- class (id, class_name)
a student can have multiple classes associated with him/her
I need to take all student records with class details such as class name, block, etc...
I am getting duplicate rows for students (with one class for each duplicate student)
I used this query
select students.name,class.name, class.block from students
left join student_class_relation on student_class_relation.student_id=students.id
left join class on class.id=student_class_relation.class_id