需要MYSQL查询这些表

时间:2016-07-20 10:44:13

标签: mysql

学生表

enter image description here

历史表

enter image description here

我想像这样显示

id Name title1 total1 get1 year1 title2 total2 year2 title3 total3    get3 year3 
1 Usman Hayat Matric 850 600 2001 Inter 1100 900 2003 NULL NULL NULL NULL 
2 Hamid Khan  Matric 850 500 2002 Inter 1100 789 2004    BA 800 400 2006

1 个答案:

答案 0 :(得分:0)

您需要使用pivot来获取请求的结果,您可以在此处查看有关pivot的更多详细信息

MySQL pivot table

如果仍然无法编写下面的查询注释,请完成此操作将编写查询。