SELECT * , group_concat( ' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , ' ' ),group_concat(' ' , `order_id` , ' ') FROM `sale_orders` WHERE `shipments` =0 AND `number` =$id GROUP BY `recipient-name` , `ship-address-1` ORDER BY `sku`
请问group_concat( ' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , ' ' )所产生的结果能不能排序???
以下为查询的结果:
ship name sku-quantity
001-01 wang A0015-00-04-23 X 1
002-02 liu A0041-00-WW-25 X 1 , A0042-00-AC-25 X 1
003-03 li A0041-00-WW-25 X 1 , A0256-00-O6-34 X 1 , A0042-00-AC-25 X 1
004-04 fang A0042-00-AC-25 X 1 , A0041-00-WW-25 X 1 , A0217-00-SI-33 X 1
sku-quantity字段整体是按照SKU来排序的,我是想要每条记录的SKU也能排序。
------解决方案--------------------
FROM `sale_orders`
改为
FROM ( select * from `sale_orders` order by `sku`) T