飞克网
标题:
mysql中字段类型转换排序
[打印本页]
作者:
admin
时间:
2021-8-24 22:18
标题:
mysql中字段类型转换排序
所以我们也可以用CAST解决问题:
select server_id from cardserver where game_id = 1 order by CAST(server_id as SIGNED) desc limit 10;
+-----------+
| server_id |
+-----------+
| 10 |
| 8 |
| 7 |
| 6 |
| 5 |
| 4 |
| 3 |
| 2 |
| 1 |
+-----------+
也可以使用CONVERT来搞定此问题:
select server_id from cardserver where game_id = 1 order by CONVERT(server_id,SIGNED) desc limit 10;
+-----------+
| server_id |
+-----------+
| 10 |
| 8 |
| 7 |
| 6 |
| 5 |
| 4 |
| 3 |
| 2 |
| 1 |
+-----------+
欢迎光临 飞克网 (http://sou-a.com/)
Powered by Discuz! X3.2