毕设的学习(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。

猜你喜欢

转载自www.cnblogs.com/ChangeMyWorld/p/11792202.html