mysql行转换列

利用max(case when then)

表结构:

select name as 姓名,
max(
case
when subject='语文' then score
end
) as '语文',
max(
case
when subject='数学' then score
end
) as '数学'

from student group by name;

原文地址:https://www.cnblogs.com/wu-peng/p/12778060.html