0

I cant seem to get around this issue. I'm new to MYSQL and been trying some stuff out. Spare some time to help??

SELECT stu.stud_id Student_ID, stu.lastname Student_Name, sec.sect_id, a.attend_status Attendance_Status, date(a.datetime) Attendance_Date 
FROM student stu 
INNER JOIN attendance a ON (stu.stud_id=a.stud_id) 
INNER JOIN section sec ON (a.sect_id=sec.sect_id) 
GROUP BY a.datetime  

output of the query above

expected output:

   +----+-----------+-----------+-----------+-----------+ 
   | id |    name   | 2018-02-07| 2018-02-08| new date  |
   |    |           |           |           | if added  |
   +----+-----------+-----------+-----------+-----------+ 
   |  1 |    Alupig |   present |      null |    ----   |
   |  3 |     Perez |   present |      null |    ----   | 
   |  2 |    Verana |      null |   present |    ----   | 
   +----+-----------+-----------+-----------+-----------+  
Rishikesh Dhokare
  • 3,559
  • 23
  • 34
  • Have a look at [this answer](https://stackoverflow.com/a/9668036/851432) – Jomoos Feb 15 '18 at 04:39
  • @Jomoos I don't think it answer the problem, it's for fixed columns. –  Feb 15 '18 at 04:46
  • Unfortunately MySQL does not have a `PIVOT` function which is basically what you are trying to do. So you will have to resort to `CASE` statement. :/ – Jomoos Feb 15 '18 at 04:48
  • if we add php and javascript in the picture, would pivoting then be possible? –  Feb 15 '18 at 04:57
  • FYI-This is not an answer but will help you. https://stackoverflow.com/questions/1241178/mysql-rows-to-columns – Kedar Limaye Feb 15 '18 at 05:01
  • Seriously consider handling issues of data display in application code – Strawberry Feb 15 '18 at 08:15

0 Answers0