mysql如何重复数据合并_mysql合并重复数据
有一張關(guān)鍵字表,有如下字段
art_id
keyword
last_modify
因?yàn)橐黄恼略试S有多個(gè)關(guān)鍵字,所以會(huì)產(chǎn)生如下情況的數(shù)據(jù)記錄
1 電子商務(wù) 2014-4-7
1 b2c 2014-4-7
現(xiàn)在,要對(duì)這種情況的數(shù)據(jù)進(jìn)行處理,去除重復(fù),合并關(guān)鍵字,合并后的結(jié)果如下
1 電子商務(wù)|b2c 2014-4-7
現(xiàn)在思路是:1,先創(chuàng)建臨時(shí)表;
2,把使用group_contcat函數(shù)合并行后的結(jié)果,插入臨時(shí)表;
3,清空原表;
4,再把臨時(shí)表的數(shù)據(jù)插回原表。
sql語句:1,Create temporary table temp as( select art_id,group_concat(keyword separator '|' ),last_modify from keyword group by art_id);
2,truncate table keyword
3,insert into keyword( art_id,keyword,last_modify) select * from temp
總結(jié)
以上是生活随笔為你收集整理的mysql如何重复数据合并_mysql合并重复数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iphoneX系列手机在页面滚动时隐藏底
- 下一篇: MySQL将多条数据合并成一条