hi, im trying to insert a record into a mysql database using php. If the record exists, I do not want to insert the record. I want to be able to do this with one query. I know its possible with 2 queries.
The sql statement that im using is:
INSERT INTO tblSampleSetProduct (sampleSetID, productID) VALUES ('2', '11') WHERE NOT EXISTS (SELECT sampleSetProductID FROM tblSampleSetProduct WHERE sampleSetID = 2 AND productID = 11)
The error im getting is:
You have an error in your SQL syntax near 'WHERE NOT EXISTS (SELECT sampleSetProductID FROM tblSampleSetProduct WHERE sampl' at line 1
The stucture of the table is:
tblSampleSetProduct
sampleSetProductID primary key int auto_increment
sampleSetID int
sampleSetID int
The database is ok as I currently have the code setup to check if the record exists (1st query) then insert record (2nd query)
Any help would be great. Thanks in advance