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

mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -

mysql - How to insert just year and month into date field? -