Database - MysqlOrderby

ORDER BY FIELD & ORDER BY FIND_IN_SET

where ~ in (…)에서 in조건 순서대로 정렬하고 싶을때

SELECT * FROM foo where id in (2,3,1) ORDER BY FIELD(id,2,3,1);  
SELECT * FROM foo where id in (2,3,1) ORDER BY FIND_IN_SET(id,"2,3,1");

댓글남기기