NYCPHP Meetup

NYPHP.org

[nycphp-talk] OT: Random MySQL question

Flavio daCosta nyphp at n0p.net
Wed Feb 14 14:12:59 EST 2007


On 02/14/2007 01:46 PM, Adrian Noland wrote:
> I have the following query:
> select id, categories from dd_categories where id in (21, 20, 13, 3, 22,
> 31);
> 
> I want category 21 to show up first in the list.

SELECT
	id, categories
FROM
	dd_categories
WHERE
	id IN (21, 20, 13, 3, 22, 31)
ORDER BY
	FIELD(id, 21) DESC, id;


http://dev.mysql.com/doc/refman/5.0/en/string-functions.html





More information about the talk mailing list