I download an XML file containing 1048 records, and then I successfully create a table($today) in my DB, and load the XML data into the MySQL table.
I then run a second script which contains this query:
INSERT INTO
t1
(
modelNumber,
salePrice
)
SELECT modelNumber,salePrice
FROM `'.$today.'`
ON DUPLICATE KEY UPDATE t1.modelNumber=`'.$today.'`.modelNumber,
t1.salePrice=`'.$today.'`.salePrice
");
It works, but I’m losing 11 records. The total count is 1037, while the $today table has the exact amount of records contained in the XML file (1048).
How can I correct this problem?
Runs some queries on the $today to find your 11 duplicates.
The ON DUPLICATE KEY clause will suppress these 11 records.