У меня есть таблица посещаемости
--------------------------------------------------------------------------- attendance_id | stud_id | week | sy |sem |present --------------------------------------------------------------------------- 1 | 1 | 02/18/2012 | 2010-2011 |1st semester|1 2 | 2 | 02/18/2012 | 2010-2011 |1st semester|1 3 | 3 | 02/18/2012 | 2010-2011 |1st semester|1 4 | 1 | 02/25/2012 | 2010-2011 |1st semester|1 5 | 2 | 02/25/2012 | 2010-2011 |1st semester|1 6 | 1 | 03/03/2012 | 2010-2011 |1st semester|1 7 | 2 | 03/03/2012 | 2010-2011 |1st semester|1 8 | 3 | 03/03/2012 | 2010-2011 |1st semester|1
мой запрос – это
Select cadet_record.fname,cadet_record.lname,cadet_record.mname, student_id, MAX(case WHEN week = '02/18/2012' then present end) as 'week1', MAX(case WHEN week = '02/25/2012' then present end) as 'week2' From attendance LEFT JOIN cadet_record ON cadet_record.stud_no = attendance.student_id WHERE section = '$section' AND schoolyear = '$year' AND component = '$component' AND semester = '$semester' GROUP BY student_id
как я могу динамически звонить всю неделю, не вставляя даты, например, 02/28/2012, 02/29/2012 и так далее и т. д. есть идеи? знак равно