I’m using this query:
SELECT * FROM `challenges` WHERE id IN (#, #, #, #)
Where the #’s are 4 ID numbers associated with a single row. This works well since it allows me to pull out 4 rows from the table in one query, but there’s an odd issue with it. I don’t know why it does it like this, but the order of the rows in the result isn’t the same as the order I have them in in the query. For example:
SELECT * FROM `challenges` WHERE id IN (108, 208, 134, 142)
I want them to come out in that order, but they instead come out like this:
108, 134, 142, 208
The only thing I notice is that each row in the challenges table has a field called “first_recorded”, and the order of the rows coming out of this query is sorted by that field, ascending. Is there any way to force the query to order the results in the same order as the IDs are ordered?
You need to order by field