一个varchar 的字段 存放 1,2 11等
将字段*1或者+0可以将MySQL字符串字段按数值排序
select * from table where 1 order by id+0 desc;
select * from table where 1 order by id*1 desc;
将字段*1或者+0可以将MySQL字符串字段按数值排序
select * from table where 1 order by id+0 desc;
select * from table where 1 order by id*1 desc;
本文介绍了一种在MySQL中将存储为字符串类型的数字字段转换为数值进行排序的方法。通过简单的数学操作如*1或+0即可实现字符串字段的数值排序。
3586

被折叠的 条评论
为什么被折叠?



