Can someone tell me how to take one record and duplicate it exactly, with
the exception of the pk, which I want to increment as usual.
I think I need insert select, however, I don't want to name all the fields,
as it would break over time, if I add or subtract fields. I seem to recall
using a
how about:
insert into table_name select * from table_name where select criteria
is the primary key an auto sequence?
-Original Message-
From: Scott Haneda [EMAIL PROTECTED]
Sent: Sep 14, 2006 5:06 PM
To: MySql mysql@lists.mysql.com
Subject: Cloning or duplicating a record
Can someone
how about:
insert into table_name select * from table_name where select criteria
is the primary key an auto sequence?
Yes, pk is on auto increment
--
-
Scott HanedaTel: 415.898.2602
how about:
insert into table_name select * from table_name where select criteria
is the primary key an auto sequence?
This is what happens when I try:
insert into logbook select * from logbook where id = 1;
ERROR 1062: Duplicate entry '1' for key 1
--
At 3:31 PM -0700 9/14/06, Scott Haneda wrote:
how about:
insert into table_name select * from table_name where select criteria
is the primary key an auto sequence?
This is what happens when I try:
insert into logbook select * from logbook where id = 1;
ERROR 1062: Duplicate entry '1' for
YOu'll have to list the fields explicitly, except for the primary
key. For example, if your table has columns:
id (PK)
data_1
data_2
data_3
you should be able to do
insert into table_name (data_1, data_2, data_3) select
data_1,data_2,data_3 from table_name where id=1
The