How to insert data only if data doesn't already exist in MYSQL?
This is what I'm doing right now:
Execute a query and check if the date to be inserted already exists in a table.
If date doesn't exist:
Another query wil开发者_如何学Gol insert the date into the table.
How can these two query be combined?
IF NOT EXISTS (SELECT * FROM X WHERE A=B)
INSERT INTO ...
Taken from here:
INSERT IGNORE INTO Table (EmailAddr) VALUES ('test@test.com')
you can put the two statements together into a stored procedure
精彩评论