Here is the simple query with IN clause. But the problem is i need to get the output in the same order of the ids.
SELECT GROUP_CONCAT(username) as users FROM usertable WHERE usr_id IN (54,68,46)
For example if i pass 54,68,46 then the row with usr_id 54 should come first then 68 and then 46 should come. Is there any way to achieve this in MySQL?
We can use
FIND_IN_SETon order by clause to get the values in same order like this.But i don’t know how to
GROUP_CONCATin the same order. If anybody gives the answer for that in these kind of simple approach, i can accept that answer.