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 key 1
--
-------------------------------------------------------------
Scott Haneda Tel: 415.898.2602
<http://www.newgeo.com> Novato, CA U.S.A.
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 insert failed because you were - as the error message said -
trying to insert a record with an existing primary key, which is
unique.
Check mysql manual for more info on syntax of insert command.
steve
--
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center [EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]