I have problems sorting results from MySQL. Here is the code:
$my_query = "
SELECT *
FROM tbl1, tbl2, tbl3
WHERE tbl1.id = tbl2.id2
AND tbl1.sub_id = tbl3.sub_id
AND tbl1.id IN(22, 55, 5, 10, 40, 2001, 187)
";
This query works fine, but when I print it, it’s ordered by tbl1.id ASC. I want to display the same order as I used in IN(22,55,5,10,40,2001,187).
I think it is possible, but I tried my best and did not get it fixed. Is there any solution that works for me?
Add this ORDER BY clause that uses the FIELD function to get the order you want: