mysql把字符串转化为整数

1、字段column_name+0

例如:将pony表中的d 进行排序,可d的定义为varchar,可以这样解决

select * from pony order by (d+0);


2、cast(字段 as unsigned)
例如:将表A记录按name 字段从小到大排列
select * from A order by cast(name as unsigned);

你可能感兴趣的:(MySQL)