Thread: help with query
View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 10:50 AM
Captain Paralytic
 
Posts: n/a
Default Re: help with query

On 16 May, 09:55, Aahz <juno10...@hotmail.com> wrote:
> select number,name,age,address from people
> where number in (88,4,2,6,8,1,166,33)
>
> How I make this to have order by exact numbers as in query. I want
> result to be ordered like this:
>
> 88
> 4
> 2
> 6
> 8
> 1
> 166
> 33
>
> and not
>
> 1
> 2
> 4
> .....etc
>
> and not by name or anything else
>
> How to do this ? Thank you


SELECT
`number`,
`name`,
`age`,
`address`
FROM `people`
WHERE `number` IN (88,4,2,6,8,1,166,33)
ORDER BY FIND_IN_SET(`number`,'88,4,2,6,8,1,166,33')

Reply With Quote