select t.student_id, t4.name, t5.name, ifnull(t6.name,"")
from student_info t
left join student_type t1 on t.student_id=t1.student_id and t1.level=0 left join student_type_info t4 on t1.type_id=t4.id
left join student_type t2 on t.student_id=t2.student_id and t2.level=1 left join student_type_info t5 on t2.type_id=t5.id
left join student_type t3 on t.student_id=t3.student_id and t3.level=2 left join student_type_info t6 on t3.type_id=t6.id
order by t.student_id;
时间: 2024-10-19 15:39:55