Display Rows From Mysql Query As Columns In Html Table
I have a MYSQL database storing levels for students for each terms work. I'm fine creating the php page, with query etc and very comfortable with the hmtl/css required to create ta
Solution 1:
You need to pivot your results. Unfortunately MySQL does have PIVOT
but you can build a query like this to achieve the same results
SELECT student_id,
MAX(CASEWHEN term ='aut7'THEN level END) Aut7,
MAX(CASEWHEN term ='spr7'THEN level END) Spr7,
MAX(CASEWHEN term ='sum7'THEN level END) Sum7
FROM student_terms
GROUPBY student_id
See demo in SQL Fiddle
Post a Comment for "Display Rows From Mysql Query As Columns In Html Table"