码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2015-04-02 13:14:03      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

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
;

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

标签:

原文地址:http://www.cnblogs.com/shouwangzhe-/p/4386517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!