Jump to content

problem in insert with on duplicate key update


newphpcoder
 Share

Recommended Posts

Hi..I have code for importing data from .xml file to database.My issue is the On Dupliicate Key Update did not work, ti save again the data even the data is already exist..here is my code:

$sql = "INSERT INTO sales_order (ProductType,WorkOrder,POIssueDate,SalesMonth)	  VALUES	  ('$ProductType','$WorkOrder','$POIssueDate','$SalesMonth')	  ON DUPLICATE KEY UPDATE	  ProductType = '$ProductType', WorkOrder = '$WorkOrder', POIssueDate = '$POIssueDate', SalesMonth = '$SalesMonth'" or die(mysql_error());

For example I attach file then I attahc again but I update some data I want it to update on database if the ProductType is already exist and add if not.I attach my sample upload file. and You can see on the second upload the ProductType P101 change the sales month.In my query the data that was second upload was insert again it did not update the existing data.I want the result should be the second upload not mix the first and second upload. Now the data was duplicated, thats my problem. I want it to update if the ProductType is already exist. Thank you

post-42557-0-75102300-1334288772_thumb.jpg

post-42557-0-74470800-1334288780_thumb.jpg

Edited by newphpcoder
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...