select a.name,a.score 语文,b.score 化学,c.score 英语 from
(select name,score from student where course='语文' ) a
left join
(select name,score from student where course='化学' ) b
on a.name=b.name
left join
(select name,score from student where course='英语' ) c
on a.name = c.name
select name,case when course='语文' then score end as '语文',
case when course='化学' then score end as '化学',
case when course='英语' then score end as '英语'
from student;
这是列转行,行转列的话用UNION ALL