毕设的学习(15)MySQL对varchar类型数值进行排序以及 order by 、limit和where连用

对varchar类型数值进行排序  

 

select * from score where score_activity_id = '1' order by material_score_total DESC;

 

此时并不生效,material_score_total 为varchar数值。

正确做法:

select * from score where score_activity_id = '1' order by material_score_total+0  DESC;

在该字段后加0;

 

order by 、limit和where连用:

先使用where,再使用order by 、limit。

 

欢迎大家关注我的微信公众号,获取你不知道的宝藏。

posted @ 2019-11-04 15:15  代码改变我的世界  阅读(432)  评论(0编辑  收藏  举报