I have a need to do an insert to MySQL where a record does not exist in the destination table already
my query
INSERT INTO comment (`mid`, `pid`, `comment_text`, `comment_date`, `comment_type`)
VALUES (180, 2, NULL, '2012-07-26 10:19:00', 'tag') WHERE NOT EXISTS ( SELECT * FROM `comment` WHERE `mid`=180 AND `pid`=2 AND `comment_type`='tag')
however when this runs I get this error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE NOT EXISTS ( SELECT * FROM
comment
WHEREmid
=180 AND `pid' at line 2
Any ideas essentially i want to stop duplicate rows being added to this table when they match the values