If i select like this:
SELECT id FROM users WHERE id IN(3,4,8,1);
This by default will select users in this order
1,
3,
4,
8,
I would like to select them in the same order that i put IN() values so:
3,
4,
8,
1
is this possible?
Use FIELD() for that
SELECT id
FROM users
WHERE id IN(3,4,8,1)
order by field(id, 3,4,8,1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With