mysql insert 1062_一则 insert 报 ERROR 1062 (23000): Duplicate entry 'xxx' for key,请帮忙看看...
本帖最后由 likinglife 于 2016-1-5 17:38 編輯
wmxcn2000 發(fā)表于 2016-1-5 15:47
ic_t表,現(xiàn)在里有數(shù)據(jù)吧?數(shù)據(jù)清空后再insert還是這個情況,發(fā)現(xiàn)在insert過程中會產(chǎn)生類似數(shù)據(jù)合并的現(xiàn)象導致數(shù)據(jù)重復(fù):
--我的原表沒有重復(fù)數(shù)據(jù)
mysql> SELECT attr_name_id,VALUE FROM t WHERE is_delete=1 and attr_name_id = 783 and value like '%ContiCrossContact LX%';
+--------------+-----------------------+
| attr_name_id | VALUE? ?? ?? ?? ?? ???|
+--------------+-----------------------+
|? ?? ?? ? 783 | ContiCrossContact LX2 |
|? ?? ?? ? 783 | ContiCrossContact LX??|
+--------------+-----------------------+
--insert過程中,會產(chǎn)生類似數(shù)據(jù)合并導致重復(fù)數(shù)據(jù),例如insert后ContiCrossContact LX2沒有了,變成兩個ContiCrossContact LX
mysql> select attr_name_id,attr_value,count(*) from ic_t where attr_name_id=783 GROUP BY attr_name_id,attr_value HAVING COUNT(*)>1;
+--------------+----------------------+----------+
| attr_name_id | attr_value? ?? ?? ???| count(*) |
+--------------+----------------------+----------+
|? ?? ?? ? 783 | ContiCrossContact LX |? ?? ???2 |
|? ?? ?? ? 783 | ContiPremiumContact??|? ?? ???2 |
|? ?? ?? ? 783 | ContiSportContact 5??|? ?? ???2 |
|? ?? ?? ? 783 | Eagle F1 Asymmetric??|? ?? ???2 |
+--------------+----------------------+----------+
mysql> SELECT attr_name_id,attr_VALUE FROM ic_t WHERE attr_name_id = 783 and attr_value like '%ContiCrossContact LX%';
+--------------+----------------------+
| attr_name_id | attr_VALUE? ?? ?? ???|
+--------------+----------------------+
|? ?? ?? ? 783 | ContiCrossContact LX |
|? ?? ?? ? 783 | ContiCrossContact LX |
+--------------+----------------------+
為什么會這樣呢?
總結(jié)
以上是生活随笔為你收集整理的mysql insert 1062_一则 insert 报 ERROR 1062 (23000): Duplicate entry 'xxx' for key,请帮忙看看...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 10分钟_10分钟入门mys
- 下一篇: mysql集群数据引擎_MySQL数据引