Cloning or duplicating a record

2006-09-14 Thread Scott Haneda
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

Re: Cloning or duplicating a record

2006-09-14 Thread hwigoda
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

Re: Cloning or duplicating a record

2006-09-14 Thread Scott Haneda
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

Re: Cloning or duplicating a record

2006-09-14 Thread Scott Haneda
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 --

Re: Cloning or duplicating a record

2006-09-14 Thread Steve Edberg
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

Re: Cloning or duplicating a record

2006-09-14 Thread Scott Haneda
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