Andrew Darby wrote:
Good people of php-db, I think I have this solved. For those keeping
score, repeating the CASE condition in the ORDER BY seems to work,
i.e.,
SELECT DISTINCT e.exhibition_id, e.title, e.begin_date,
CASE 'heading'
WHEN UNIX_TIMESTAMP( ) >= e.begin_date
THEN 'Coming Up'
ELSE 'Now Showing'
END 'heading',
e.end_date, special
FROM exhibition e
WHERE e.end_date >= UNIX_TIMESTAMP( )
ORDER BY
CASE
WHEN UNIX_TIMESTAMP( ) >= e.begin_date
THEN 'Coming Up'
ELSE 'Now Showing'
END , e.begin_date ASC
I don't know why, however.
I think that's an sql standard thing.. because the "heading" column is
being made up (by the case statement) you can't use the alias in an
order by or group by.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php