开发者

mysql order by not sorting

I cant seem to figure out whats preventing this ORDER BY declaration to not affect the query results...

SELECT `vendor_orders`.`id`, `vendor_orders`.`vendor_order_id`, 
`vendor_orders`.`order_number`, `vendor_orders`.`customer_order`, 
`vendor_orders`.`order_date`, `vendor_orde开发者_开发百科rs`.`status`, `vendors`.`name` AS 
`vendor_name`, COUNT( `vendor_order_items`.`id` ) AS `order_item_count`  
FROM (`vendor_orders`, `vendors`, `vendor_order_items`) 
WHERE `vendor_orders`.`aid` = 'c4ca4238a0b923820dcc509a6f75849b'   
AND `vendor_orders`.`vendor_id` = `vendors`.`vid`  
AND `vendor_order_items`.`vendor_order_id` = `vendor_orders`.`vendor_order_id`  
GROUP BY `vendor_orders`.`id`  
ORDER BY 'order_item_count' DESC  
LIMIT 0,10


Looks like you are using ' instead of using the back apsotrophe like you have with the other column declarations.


try to use

ORDER BY COUNT(vendor_order_items.id) DESC

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜