Considering this MySQL query:
SELECT
someColumns
FROM
someTable
WHERE
someColumn IN ( value1, value2, value3 )
… how can I guarantee that the rowset comes out ordered in the exact order of the values given to the IN () clause? I presume this is not guaranteed without giving it an ORDER BY clause, is it?
PS.:
The values to the IN () clause will be an array of arbitrary data passed to the query by PHP (utilizing Zend Framework’s select statement) in the following manner:
->where( 'someColumn in (?)', $theArrayWithValues );
Use a CASE statement in the ORDER BY:
Assign the arbitrary values as you like. I don’t normally include
ASCinORDER BYbecause it is implied if not defined, but I wanted to be explicit in case you want inDESCorder.