Home >Database >Mysql Tutorial >mysql根据in中出现的先后顺序排序_MySQL

mysql根据in中出现的先后顺序排序_MySQL

WBOY
WBOYOriginal
2016-06-01 13:36:07780browse

bitsCN.com

mysql根据in中出现的先后顺序排序

 

有的时候我们需要根据in的列表进行排序,而并且一般的升降序

   www.bitsCN.com  

Sql代码  

select * from user where user_id in (10084960310007011,10029627710007011,100000000001206373)  

 order by find_in_set(  

    user_id ,  

    '10084960310007011,10029627710007011,100000000001206373')  

 

 这样查询出来的数据第一个是10084960310007011,第二个是10029627710007011,第三个是100000000001206373

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn