Re: Re: Help! With MySQL CASE problem
| From: | Chris | Date: | Mon, 16 Oct 2006 00:21:37 +0000 |
| Subject: | Re: Re: Help! With MySQL CASE problem | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42555@lists.php.net to get a copy of this message | ||
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/