I have a query like this: SELECT * FROM table WHERE id IN (2,4,1,5,3);
However, when I print it out, it\'s automatically sorted 1,2,3,4,5. How can we ma
The Ordering by field never worked for me. I had a list of countries and I needed United States and Canada to appear on top of the list, so my query was like this:
SELECT * FROM countries ORDER BY code='USA', code='CAN', name ASC
This never worked, but I realized that the ordering was different, it was showing Canada and the States at the end of the list, so I did this:
SELECT * FROM countries ORDER BY code!='USA', code!='CAN', name ASC
And it worked... why? Beats me, but it just did; try it as well.