如果不使用cast
select 总表,字频,韵脚 from 字频 where 字频>10000 order by 字频 limit 5;
result:
+--------+---------+---------+
| 总表 | 字频 | 韵脚 |
+--------+---------+---------+
| 渐 | 100054 | an an |
| 蒲 | 10012 | u |
| 扩 | 100193 | o |
| 保 | 1003678 | ao |
| 骚 | 10039 | ao ao |
+--------+---------+---------+
5 rows in set (0.00 sec)
没有按预想的进行大小排序,因为字频字段是varchar属性
本来甚至想转换字频字段的属性,中途不知道有多麻烦
但是发现了cast
使用cast
select 总表,字频,韵脚 from 字频 where 字频>10000 order by cast(字频 as unsigned integer) limit 5; # or signed integer
result:
+--------+--------+---------+
| 总表 | 字频 | 韵脚 |
+--------+--------+---------+
| 蒲 | 10012 | u |
| 骚 | 10039 | ao ao |
| 玫 | 10041 | ei |
| 潭 | 10059 | an |
| 誓 | 10071 | i |
+--------+--------+---------+
5 rows in set (0.00 sec)
有点骚
Q.E.D.
Comments | 0 条评论