SELECT id FROM films WHERE id IN (90,4,40)
结果
4
40
90
但我希望它返回90,4,40 我应该做什么? (mysql)
抱歉,但还有一个问题:
SELECT id FROM films WHERE id IN(90,4,40)ORDER BY FIELD(id
,90,4,40)没问题
但如实地
for ( $i = 1; $i <10; $id ++ ){
$IDarray[] = random();
}
SELECT id FROM films WHERE id IN "(". implode(',',$IDarray). " ) ";
我希望按ID排序,但ID是随机的,我希望保持ID随机顺序
答案 0 :(得分:3)
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)