子查询作为列

select s.*,
case s.gender when 1 then '男' when 0 then '女' end as gender_text,
(select name from dic_school  where id=s.school) as school_text,
(select d.name from dictionary d where d.id=s.STATUS) as status_text ,
(select group_concat(staff.name)  from student_owner ,staff  where student_owner.student_id=s.id and student_owner.staff_id=staff.id) as owner_text,
(select d.name from dictionary d where d.id=s.source) as source_text ,
(select group_concat(tag.name)  from student_tag ,tag  where student_tag.student_id=s.id and student_tag.tag_id=tag.id) as tag_text

from student s inner join student_owner so on s.id=so.student_id and so.staff_id='2'

原文出处:/show_1EFGQaOI03r.html