标签:
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;
mysql 纵表转横表 需要用join不能直接where连接
标签:
原文地址:http://www.cnblogs.com/haiwangxing598/p/5458810.html