mysql 蠕虫复制出错

WBOY
Release: 2016-06-23 14:17:29
Original
1539 people have browsed it

版本:mysql 5.5
我有一张wish表是这样的:
+----+------+----------------------+
| id | name | wish                 |
+----+------+----------------------+
|  1 | 张飞    | 好久没有见到大哥了!
+----+------+----------------------+

我想复制表中的第一条记录,
insert into wish select * from wish;
或者 
insert into wish select name,wish from wish;
或者
insert into wish
(name,wish)
values
select * from wish;

以上均报错,主要是报ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'


回复讨论(解决方案)

因为你的id是主键,主键是唯一的。
insert into wish(name,wish) select name,wish from wish;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template