Hello all,
I got a query that insert new record is not present and update the existing ones if available.
I got a AUTO_INCREMENT field that is the number of row.
If I run more than one time the same query that field run always as it would be a new insert also if it’s not.
Another strange thing is that the number jumps 2 numbers (from 10 to 13 instead of 11)
Is there a trick to avoid that behavior ??
$sql_insert_rows="INSERT INTO orders_details (OrderID , CustomerID, SalesmanID , OrderDate , ProductID , UnitPrice , CurrencyID , Quantity)
SELECT OrderID , CustomerID, SalesmanID , OrderDate , ProductID , UnitPrice , CurrencyID , Quantity
FROM orders_details_temp
ON DUPLICATE KEY UPDATE
orders_details.OrderID = orders_details_temp.OrderID ,
orders_details.CustomerID = orders_details_temp.CustomerID,
orders_details.SalesmanID = orders_details_temp.SalesmanID,
orders_details.OrderDate = orders_details_temp.OrderDate,
orders_details.ProductID = orders_details_temp.ProductID ,
orders_details.UnitPrice = orders_details_temp.UnitPrice ,
orders_details.CurrencyID = orders_details_temp.CurrencyID,
orders_details.Quantity = orders_details_temp.Quantity ";
See image to understand better
Thanks