-2
Follow a following code snippet:
SELECT user_id, name, firstname
FROM vrp_user_identities
WHERE user_id IN (27, 2, 1, 365, 142)
Returns me an array only with the data I want, but it comes in ascending form when using the IN
instead of first coming the data from ID 27
he first pulls the data from ID 1
and so on.
How could I get around this?
It depends on which SQL engine you are using. In large part you can use
ORDER BY user_id=142,user_id=365,user_id=1,...
- see working here - in others may use specific functions such asORDE BY FIND_IN_SET( user_id,'27,2...')
, etc. Only, probably, even if you edit the question and some answer comes out, it’s not what you really need, which is what we call XY problem.– Bacco