Reputation: 1524
How to ORDER BY id based on id inside IN
SELECT * FROM mall WHERE mall_id IN (3331083,33310110,3331080,33310107,33310119,3331410) AND mall_status='1' LIMIT 50
the result should be :
Upvotes: 3
Views: 65
Reputation: 37365
You need FIELD function:
SELECT * FROM mall WHERE mall_id IN (3331083,33310110,3331080,33310107,33310119,3331410) AND mall_status='1' ORDER BY FIELD(mail_id, 3331083,33310110,3331080,33310107,33310119,3331410) LIMIT 50
Upvotes: 6