Afficher un message
Vieux 30/10/2007, 12h15   #6
Johan Höök
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sort results by order in list

Hi,
what you probably want is
SELECT id, start_date FROM iddt WHERE id IN
('109k7','s3x6','sxmns','wt57')
ORDER BY FIELD(id,'109k7','s3x6','sxmns','wt57')

/Johan

Papalagi Pakeha skrev:
> On 10/30/07, Sebastian Mendel <lists@sebastianmendel.de> wrote:
>> Papalagi Pakeha schrieb:
>>> Hello,
>>>
>>> I have a query like:
>>> SELECT id, start_date FROM iddt WHERE id IN ('109k7','s3x6','sxmns','wt57');
>>> which gives me:
>>> +-------+---------------------+
>>> | id | start_date |
>>> +-------+---------------------+
>>> | 109k7 | 2007-10-07 12:06:58 |
>>> | sxmns | 2007-10-06 02:17:30 |
>>> | wt57 | 2007-10-07 15:57:37 |
>>> | s3x6 | 2007-10-07 08:58:20 |
>>> +-------+---------------------+
>>>
>>> How can I get the results sorted by the order in which they appear in
>>> the ID list?

>> i do not fully understand ... ORDER BY `id` ... ???
>> what ID List?

>
> This ID list: ('109k7','s3x6','sxmns','wt57')
> I.e. I want to get the results in the same order in which they appear
> in the above list. 109k7 first, s3x6 second, etc. Simple WHERE id IN
> (...) gives me random order.
>
> PaPa
>

  Réponse avec citation
 
Page generated in 0,05980 seconds with 9 queries