I have a query like this:
SELECT title,id FROM table1 WHERE id IN ('2','7','4','10')
The result set is ordered by id by default, but I need it in the exact order of numbers in above set.
How can I achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
FIELD()function should be able to do this:See also MySQL sort after argument in IN().