Hi all,
I am trying to write a SELECT query that has a conditional ORDER BY statement something like the following:
$DayNumber = date("w", time());
SELECT DayNumber, CodeShare, ScheduledDateTime, ScheduledTime, Flight, Logo, IATALookup, RemarksWithTime, Terminal, Gate FROM LHRFlightStats24 WHERE ArriveDepart = 'I' AND Terminal = '4' ORDER BY CASE". $DayNumber == "0" ." THEN DayNumber DESC ELSE DayNumber ASC, ScheduledTime ASC, IATALookup ASC
If the current day number is "0" then order by "DayNumber DESC" else order by "DayNumber ASC".
The query I have is producing an error but the error is not clear to me:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 35' at line 1
Can anyone see where I am going wrong.