MySQL - SELECT ... WHERE id IN (..) - correct order -


i have following query

select * table id in (5,4,3,1,6) 

and want retrieve elements in order specified in "id in.." meaning should return:

5 .... 4 .... 3 .... 1 .... 6 .... 

any ideas how that?

use field():

select * table id in (5,4,3,1,6) order field(id, 5,4,3,1,6); 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -