is it possible to convert mysql rows to columns in this manner?
suppose i have a table like this
+-----+--------------+---------+--------------+-------+
| id | std_no | exam_id | subject_code | score |
+-----+--------------+---------+--------------+-------+
| 1 | 1000 | 1 | 101 | 70 |
| 2 | 1000 | 1 | 102 | 75 |
| 3 | 1000 | 1 | 121 | 75 |
| 4 | 1000 | 1 | 231 | 69 |
| 7 | 1001 | 1 | 101 | 80 |
| 8 | 1001 | 1 | 102 | 70 |
| 9 | 1001 | 1 | 121 | 90 |
| 10 | 1001 | 1 | 231 | 80 |
| 127 | 1000 | 2 | 101 | 61 |
| 128 | 1000 | 2 | 102 | 85 |
| 129 | 1000 | 2 | 121 | 50 |
| 130 | 1000 | 2 | 231 | 54 |
| 133 | 1001 | 2 | 101 | 63 |
| 134 | 1001 | 2 | 102 | 14 |
| 135 | 1001 | 2 | 121 | 90 |
| 136 | 1001 | 2 | 231 | 25 |
+-----+--------------+---------+--------------+-------+
and i need to create a new table based on the above like this:
+-----+----------------+-------------+-------+-------+
| id | std_no |subject_code | exam1 | exam2 |
+-----+----------------+-------------+-------+-------+
| 1 | 1000 | 101 | 70 | 61 |
| 2 | 1000 | 102 | 75 | 85 |
| 3 | 1000 | 121 | 75 | 50 |
| 4 | 1000 | 231 | 69 | 54 |
| 5 | 1001 | 101 | 80 | 63 |
| 6 | 1001 | 102 | 70 | 14 |
| 7 | 1001 | 121 | 90 | 90 |
| 8 | 1001 | 231 | 80 | 25 |
+-----+----------------+-------------+-------+-------+
as in go through the first table,get the std_no,subject_code,and score.however i need to put the score inside table2 under exam1 if table1.exam_id=1 and in table2 under exam2 if table1.exam_id=2
is this possible with mysql ?