I want to import bulk data from XML file into my database.
I am using the following query:
LOAD XML LOCAL INFILE '$fullpath'
REPLACE INTO TABLE `patients`ROWS IDENTIFIED BY '<ApptOutput>'
There is a unique key in XML data called appt_id
and I have made this appt_id
as unique in my database table.
Data is inserting well but if there is any duplicate entry occurs, it removes the old entry and inserts a new row.
I also related the patient table by primary key id
with another table.
Now, the problem is that on every duplicate entry it removes the primary key also and inserts a new entry every time.
Is there any way to update data without deleting old entry?
Means I want to make two field same as it, primary key id
and unique field from The XML.
Unique id in XML is a string, I can't make it as primary key.
Conclusion: I just want to update duplicate entry instead of deleting old one and insert new one.
I have gone through these link also but not much useful load data infile with counting duplicate rows in mysql