mysql在连接中将行值显示为列
我有三张桌子mysql在连接中将行值显示为列,mysql,join,Mysql,Join,我有三张桌子 classes id class 1 10th 2 9th 3 8th .... students id name class_id... 1 smith 2 2 gyle 3 ...... attendances id date student_id attendance 1 2014-01-01 1 P 2 2014-01-01 2 A 3 2014-01-02
classes
id class
1 10th
2 9th
3 8th
....
students
id name class_id...
1 smith 2
2 gyle 3
......
attendances
id date student_id attendance
1 2014-01-01 1 P
2 2014-01-01 2 A
3 2014-01-02 1 P
4 2014-01-02 2 P
.....
我想按日期显示每组每堂课的在校生总数,如下所示
date 10th 9th 8th .....
2014-01-01 12 11 13 .....
2014-01-02 13 11 12 .....
2014-01-01 13 10 13 .....
....................................
…您尝试了什么?这是一个pivot查询,mysql不支持它们。解决办法很快就会变得难看。执行常规联接查询,然后在代码中执行行->列转换。这是一个非常简单的代码,与在查询中使用透视相比,您在这方面花费的时间更少。我尝试了简单的连接,以行显示,但我不知道如何实现这一点