---
title: "mysql根据in中出现的先后顺序排序"
author: "bernoulli"
date: "2013-02-22T19:08:08Z"
tags: ["MySQL"]
categories: ["数据库"]
slug: "mysql-in"
draft: false
lastmod: "2013-02-22T19:08:08Z"
id: 1812671
url: "https://bernoulli.iteye.com/blog/1812671"
---

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

 

```
select * from user where user_id in (10084960310007011,10029627710007011,100000000001206373)
 order by find_in_set(
    user_id ,
    '10084960310007011,10029627710007011,100000000001206373')
```

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