I have a table like this:
mysql> select * from exams;
+------+------+------+-------+
| id | name | exam | score |
+------+------+------+-------+
| 1 | Bob | 1 | 70 |
| 2 | Bob | 2 | 77 |
| 3 | Bob | 3 | 71 |
| 4 | Bob | 4 | 70 |
| 5 | Sue | 1 | 89 |
| 6 | Sue | 2 | 87 |
| 7 | Sue | 3 | 88 |
| 8 | Sue | 4 | 89 |
+------+------+------+-------+
and I want to pivot the table by exam column so as to create 1 row for each student and 1 column for each exam.
I would like this output:
name exam1 exam2 exam3 exam4
Bob 70 77 71 70
Sue 89 87 88 89
I am using an old version of mysql, mysql 5.x
I would need some clues to achive that results.