mysql 拼接列数据
Posted wjlwo2ni
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 拼接列数据相关的知识,希望对你有一定的参考价值。
SELECT IF(@ids=w.contract_id,@num:[email protected],@num:[email protected]+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 拼接列数据的主要内容,如果未能解决你的问题,请参考以下文章