我能够创建这一行:
20131115 user_jrFeed_item_count,user_jrForum_item_count {"1":1,"1":2}
从这个数据库表中:
Chart_date chart_field chart_counts
20131115 user_jrFeed_item_count, {"1":2}
20131115 user_jrForum_item_count, {"1":1}
现在,我如何将新行插入现有表并获得以下结果:
Chart_date chart_field chart_counts
20131115 user_jrFeed_item_count , {"1":2}
20131115 user_jrForum_item_count, {"1":1}
20131115 user_jrFeed_item_count,user_jrForum_item_count, {"1":1,"1":2}
答案 0 :(得分:0)
你在找这个吗?
INSERT INTO table1(Chart_date, chart_field, chart_counts)
SELECT Chart_date,
GROUP_CONCAT(chart_field ) as chart_field,
REPLACE(GROUP_CONCAT(chart_counts),'2},{','2,') as chart_counts
FROM table1
GROUP BY Chart_date
这是 sQLFiddle 演示