Gossamer Forum
Home : General : Databases and SQL :

Data from one table to another table

Quote Reply
Data from one table to another table
Hi

I’m trying to copy all the Data from one table to another table in the same database using the following:

INSERT INTO new_tableone (row1, row2)
SELECT row1, row2 FROM tableone

Now I’m not certain that this is the best way to do it but I also get the error message

“Duplicate entry 'sometext' for key 1”

This is not a links database and “new_tableone” is empty

Regards

minesite
Quote Reply
Re: [minesite] Data from one table to another table In reply to
Have you tried just:
INSERT INTO new_tableone SELECT * FROM tableone

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] Data from one table to another table In reply to
Hi Dan

Thanks for the reply.

Quote:
INSERT INTO new_tableone SELECT * FROM tableone

Just tried it, its a lot easier but I still get the
"Duplicate entry 'sometext' for key 1"

Is there a way to remove duplicates on insert. ?

Regards

minesite
Quote Reply
Re: [minesite] Data from one table to another table In reply to
Try REPLACE INTO:

http://dev.mysql.com/...ysql/en/replace.html

Cheers,

Alex
--
Gossamer Threads Inc.