* Wilbert Enserink 
> I have a string containing recordID's in a specific order (e.g.
> $string=17,2,33,5,99)
> How can I select those records from a table in the right order (as
> determined in $string)?
> 
> SELECT * FROM table WHERE recordID IN ($string)
> 
> results in the right records but not in the order I want, instead 
> the order
> is determined by recordID... meaning (2,5,17,33,99)

Try using the FIELD() function:

SELECT * FROM table 
  WHERE recordID IN ($string)
  ORDER BY FIELD(recordID,$string)

<URL: http://www.mysql.com/doc/en/String_functions.html >

-- 
Roger

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to