I am trying to display some student score data in a single row as per subject If student UID is same. Please suggest me is it possible in a single Mysql query or I need to use php conditions for that. Here is my table after collecting the informations.
sl | uid | name | subject | score
---------------------------------------------------------
1 | a1 | AA | Math | 80
2 | b1 | BB | Math | 78
3 | a1 | AA | Physics | 70
4 | b1 | BB | Physics | 67
I want to display like this all score as per subject wise in a single row.
uid | name | math | physics
---------------------------------------------------
a1 | AA | 80 | 78
b1 | BB | 70 | 67
Here is my code and it is giving me the out put in different row. Please help me to sort out this.
SELECT DISTINCT a.uid, a.name,a.subject,a.score from STUDENT a, STUDENT b where a.uid=b.uid AND a.std=b.std GROUP BY a.uid, a.subject
Thank you