NYCPHP Meetup

NYPHP.org

[nycphp-talk] OT: Random MySQL question

Jon Baer jonbaer at jonbaer.com
Wed Feb 14 15:37:43 EST 2007


Interesting question but this *would* seem to work ...

select id, categories from dd_categories where id in (21, 20, 13, 3,  
22, 31) order by id = 21 desc;

Anyone else test, confirm or answer why?

- Jon

On Feb 14, 2007, at 1:46 PM, Adrian Noland wrote:

> Hi all,
> I have an obscure MySQL question I hope someone can answer:
>
> 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.
> It appears the default order is by id which puts #3 at the front.
> I can't order by category to get what I want, because it is in the
> middle of the alphabet.
>
> Any help? Thanks.



More information about the talk mailing list