MySQL 数字字符串按照数字排序

一个关于MySQL字符串排序,在数据里面定义的是varchar类型,实际存放的是Int类型的数据,按一下查询语句进行排序: 
将字段*1或者+0可以将MySQL字符串字段按数值排序 


如:

select * from table where 1 order by id*1 desc; 

或者:

select * from table where 1 order by id+0 desc;

除了上述方法外,这里附上一种排序方法,利用find_in_set()进行无敌排序

 

来源:https://blog.csdn.net/weixin_40607363/article/details/81776951

posted @ 2019-12-18 15:56  yangyang1900  阅读(1103)  评论(0编辑  收藏  举报