SELECT id FROM films WHERE id IN (90,4,40)
result
4
40
90
but I want it return 90,4,40 what I must do? (mysql)
SELECT id FROM films WHERE id IN (90,4,40)
result
4
40
90
but I want it return 90,4,40 what I must do? (mysql)
ORDER BY CASE `id` WHEN 90 THEN 0
WHEN 4 THEN 1
WHEN 40 THEN 2
ELSE 3
END CASE
OR
ORDER BY FIND_IN_SET(`id`, '90,4,40')
OR
ORDER BY FIELD(`id`, 90, 4, 40)
SORRY , but one more question :
SELECT id FROM films WHERE id IN (90,4,40) ORDER BY FIELD(id
, 90, 4, 40) is ok
but truthfully
for ( $i = 1; $i <10; $id ++ ){
$IDarray[] = random();
}
SELECT id FROM films WHERE id IN "(". implode(',',$IDarray). " ) ";
I want order by ID as above but ID is random, i want keep order random of ID