1
javier
exist any way to avoid duplicate entrys when i make a mysql insert? [SOLVED]
  • 2005/12/27 20:20

  • javier

  • Not too shy to talk

  • Posts: 184

  • Since: 2002/8/6 1


Hi,
Today i lost 2 forums of my board, was totally deleted, now i trying to apply my backup but i get the following error:

MySQL said:

#1062 - Duplicate entry '3' for key 1

Of course that mean the entry 3 is already in the db, but the problem is not only these entry , the problem are thousand of entrys,

Exist any way to apply my sql file avoiding these stops? (because phpmyadmin stops every time it find a duplicate entry, i want directly jump the duplicate entrys or directly overwrite)

excuse my bad english, and thanks in advance for your replys.

2
Will_H
Re: exist any way to avoid duplicate entrys when i make a mysql insert?
  • 2005/12/27 21:24

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


I have encountered the same problem on numerous occassions. The only work around that i found, was to always backup all my tables before doing anything drastic. As well as setting a schedule of backups. Then if it comes down to it, dropping all of the tables and reinserting the backup from the day before does not impact my users as much as say a backup from a month ago.

3
javier
Re: exist any way to avoid duplicate entrys when i make a mysql insert?
  • 2005/12/27 23:02

  • javier

  • Not too shy to talk

  • Posts: 184

  • Since: 2002/8/6 1


thanks for reply, i found a good way to solve my problem, i check the MySQL documents and i found the IGNORE command.

I modified my sql file, then i change:


Whit total commander i modified the sql file and replace ALL the

INSERT INTO

for:

INSERT IGNORE INTO

The command ignore simply ignore the duplicated entrys and follow adding all the entrys

best regards
Javier

Login

Who's Online

210 user(s) are online (121 user(s) are browsing Support Forums)


Members: 0


Guests: 210


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits