Search This Blog

Tuesday, February 14, 2012

mysql IN query without changing the order and maintaining the input order

mysql IN query without changing the order
e.g
SELECT FROM emp WHERE (id in ('10001', '10004','10003','10025')) ORDER BY FIELD (id,'10001', '10004','10003','10025')
this will maintain the order of 1,4,3,5
instead of the regular 1,3,4,5

No comments:

Post a Comment