Monday, 15 February 2010

php - Conditional INSERT INTO MySQL - WHERE NOT EXISTS -


I am trying to INSERT in an inquiry when the customer does not already record to purchase a product.

I have tried the SQL down, but it does not seem to work. Values ​​('$ userID', '$ product', '$ value') where the product is not present (from where the product selects the product)

  $ queryAddPurchase = "user id, product, = '$ Product' and User ID = '$ userID') ";   

The error I am getting is:

There is an error in your SQL syntax; Any advice will be appreciated!

  Add an unseen key to the optional tab purchase (`userID`,` product ') - this is just a one time Run. This table changes (UserID, Product, Price) value ('$ UserID', '$ Product', '$ Price'); Keep in mind, this prevents him from buying any product several times, which is not the desired result. / P>  

No comments:

Post a Comment