Home >Backend Development >PHP Tutorial > sql查询排序的有关问题

sql查询排序的有关问题

WBOY
WBOYOriginal
2016-06-13 13:12:271022browse

sql查询排序的问题
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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn