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

mysql 拼接列数据

时间:2019-07-02 19:28:12      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:rod   from   rom   name   sel   product   png   图片   contract   

SELECT IF(@ids=w.contract_id,@num:=@num,@num:=@num+1) AS num,@ids:=w.contract_id,w.* FROM

(SELECT (SELECT GROUP_CONCAT(project_name)
FROM production_income_data WHERE contract_id = a.contract_id) AS `names`,

(SELECT GROUP_CONCAT(project_code) FROM production_income_data
WHERE contract_id = a.contract_id) AS `codes`, a.*FROM production_income_data a )w

,(SELECT @num:=0) u,(SELECT @ids:=‘‘) m ORDER BY w.contract_id

技术图片

 

mysql 拼接列数据

标签:rod   from   rom   name   sel   product   png   图片   contract   

原文地址:https://www.cnblogs.com/wjlwo2ni/p/11122278.html

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