I have a script that I am using to migrate data from one db to another. I have already done so with using regular mysql insert and update scripts. It just takes way too long.
In any case I have dumped all of the data that I want to update in the new db to a csv, I am just worried that if I run this script I am going to get duplicate entries. I dont have an "id" that matches up so I can't do a comparison on the REPLACE script listed below. I was wondering if anyone could give me a heads up on whether or not this script looks correct.
Currently I have rows of data in the new db, I just want to overwrite any fields in the new db with this new data in the csv's if they match. The "archived_id_number" field is the only field that I could match on, but it is not a Primary Key.
Can someone shoot me the following:
I want to replace any data in fields with data in the csv's if the archived_id_number on the csv matches what is in the new db. If there is no match, the I want to insert the data as a new row.
$sql = '
LOAD DATA LOCAL INFILE "'.$theFile.'"
REPLACE INTO TABLE Product
FIELDS TERMINATED BY "|"
LINES TERMINATED BY "\\n"
(archived_id_number, sku, name, upc, account_id, shippingBox_id, unit_cost, supplier_id, description, productLength, productWidth, productHeight)
;';
Thanks for your help!!!