[英]How to sort table value using PHP and MySQL?
I need to fetch MySQL table value using one order using MySQL and PHP. 我需要使用MySQL和PHP使用一个顺序来获取MySQL表值。 I am providing my table below. 我在下面提供我的桌子。
db_cat: db_cat:
id cat_name cat_id order_no
1 aaa 10 1
2 ggg 10 30
3 fff 10 11
4 sss 10 12
5 ddd 10 5
Here I am trying to fetch data as per order_no column value by using the query : 在这里,我试图通过使用query根据order_no列值获取数据:
select * from db_cat where cat_id='10' order by order_no asc
but it is giving me the wrong order data like(11,12,30,1,5) where I should get the data like this order( 1,5,11,12,30
). 但是它给了我错误的订单数据,例如(11,12,30,1,5),在这里我应该得到像这样的订单数据( 1,5,11,12,30
)。
my order_no datatype is varchar
. 我的order_no数据类型是varchar
。
您可以按以下顺序使用演员表:
select * from db_cat where cat_id='10' order by cast(order_no as int) asc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.