select in order by , mysql排序

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 

Use FIELD() for that

SELECT id FROM users WHERE id IN(3,4,8,1)orderby field(id,3,4,8,1)

你可能感兴趣的:(mysql)