mysql多行多列合并为一行一列

ref : http://blog.csdn.net/priestmoon/article/details/7677452

 

group_concat:

group_concat(distinct name)

group_concat(name separator ';')  // 默认是,

group_concat(name order by name desc)

 

SELECT * FROM shelvesopbusinessrel;

SELECT s0.id,s0.listNum,s0.warehouseId,s0.businessQuantity,s0.productQuantity,s0.printDate,group_concat(rel.businessNum)
FROM shelvesoplist s0
left join shelvesopbusinessrel rel
on s0.id = rel.shelvesOpListId
GROUP BY s0.listNum
ORDER BY s0.id DESC
;

posted @ 2015-04-02 12:04  廖东海  阅读(546)  评论(0编辑  收藏  举报