mysql通过排序号排序无效
SQL语句:
SELECT * FROM `cn_client_goods` WHERE `id` IN ('1164','1163','1165','1166','1167','1168','1169','1170','1171','1172','1173','1174','1175','1176','1177') AND `status` = 1 ORDER BY o asc
查询结果:
结果却没有根据o 这个字段正序排列,原因在于o这个字段的类型是varchar,解决方案把o这个字段改为int类型,或者改下sql语句在查询的时候把o转化为数字类型
SELECT * FROM `cn_client_goods` WHERE `id` IN ('1164','1163','1165','1166','1167','1168','1169','1170','1171','1172','1173','1174','1175','1176','1177') AND `status` = 1 ORDER BY o+0 asc
版权声明:若无特殊注明,本文皆为《菜鸟站长》原创,转载请保留文章出处。
本文链接:mysql通过排序号排序无效 - https://wziyi.com.cn/?post=134