有没有办法在SQL中手动指定结果的顺序?

I have a PHP array of IDs of rows to retrieve from a MySQL database.

$ids = array(35, 20, 1, 5);

Is there any way I could construct an SQL query that retrieves a resource from the database with rows in that specific order of IDs?

In other words, the list of rows returned would have row with ID 35 first, then the row with ID of 20, and so on.

Try this one

<?php
$ids = array(35, 20, 1, 5);
$q = 'select * from table where id in ('.implode(',',$ids).') order by find_in_set(id, \''.implode(',',$ids).'\')' ;

Sorting on PHP/Javascript end would be easier, but one way comes to mind how you could do it in SQL:

select * from whatever where id in (35,20,1,5) order by
case id when 35 then 0 when 20 then 1 when 1 then 2 when 5 then 3 end