Return to Snippet

Revision: 58619
at July 25, 2012 13:43 by cahyadsn

Initial Code
  MAX(IF(day=1, CONCAT(subject,' ',room), '')) AS Mon, 
  MAX(IF(day=2, CONCAT(subject,' ',room), '')) AS Tue, 
  MAX(IF(day=3, CONCAT(subject,' ',room), '')) AS Wed, 
  MAX(IF(day=4, CONCAT(subject,' ',room), '')) AS Thu, 
  MAX(IF(day=5, CONCAT(subject,' ',room), '')) AS Fri 
FROM schedule 
GROUP BY period

Initial URL

Initial Description
You have a schedule table (period, day, subject, room) with a primary key period,day to avoid duplicate bookings. You wish to display the schedule as periods, subjects and rooms in rows, and days of the week in columns.

Initial Title
Pivot table Schedule

Initial Tags
mysql, table

Initial Language