Re: tricky timetable based query

2004-06-18 Thread Michael Stassen
Harald Fuchs wrote: "Sam Russo" <[EMAIL PROTECTED]> writes: I recieve a delimited file whose fields are: day,slot,subject,room An example of this file is: 2,1,Mat,R1 3,1,Sci,R6 1,2,Sci,R6 3,2,Mat,R3 1,3,Eng,R2 2,3,Eng,R5 1,4,Mat,R7 3,4,Eng,R9 I need a mysql query that will generate a timetable whi

Re: tricky timetable based query

2004-06-18 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Sam Russo" <[EMAIL PROTECTED]> writes: > I recieve a delimited file whose fields are: > day,slot,subject,room > An example of this file is: > 2,1,Mat,R1 > 3,1,Sci,R6 > 1,2,Sci,R6 > 3,2,Mat,R3 > 1,3,Eng,R2 > 2,3,Eng,R5 > 1,4,Mat,R7 > 3,4,Eng,R9 > I need a mysql que

Re: tricky timetable based query

2004-06-18 Thread SGreen
What you are trying to do is an example of what is called "pivoting" a table or "creating a pivot table". SELECT slot , max(if(day=1, concat(subject,' ',room), '')) as day1 , max(if(day=2, concat(subject,' ',room), '')) as day2 , max(if(day=3, concat(subject,' ',room), '')) as d