0
点赞
收藏
分享

微信扫一扫

select in order by , mysql排序

爱做梦的老巫婆 2022-08-05 阅读 55


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)

举报

相关推荐

0 条评论