php数字排序从mysql asc
16lz
2021-01-22
I need to get order numbers by ASC. In my mysql table It written with - (ex. 1-2; 2-3; 15-60 etc.)
我需要通过ASC获得订单号。在我的mysql表中,它是用-(例如1-2;2 - 3;15-60等等)。
Now I get order:
现在我得到订单:
15-60; 1-2; 2-3;
15-60;1 - 2;2 - 3;
why not 1-2; 2-3; 15-60?
为什么不是1 - 2;2 - 3;15-60吗?
I'm making new sorting in my opencart. Tutorial to make new sorting I used: sort by size opencart
我正在我的opencart中进行新的排序。我使用的新排序教程:按大小排序opencart
3 个解决方案
#1
3
You can try with:
你可以尝试:
SELECT *
FROM yourtable
ORDER BY numbers + 0
to automatically cast you VARCHAR column to a number, and apply the order correctly.
将VARCHAR列自动转换为数字,并正确应用订单。
Please see fiddle here.
请在这里看到小提琴。