I have to insert a few values into a mysql table, but only if there are no other (almost) equal rows, for example:
TABLE T
KEY | COL1 | COL2
1 | abc | 123
2 | def | 456
The KEY column uses auto increment, and I don't inform it on the statement, like this:
INSERT INTO T (COL1, COL2) VALUES (abc, 123)
The statement above have the same values as the first row. How can I inform mysql that I don't want to insert if the row is a duplicate like that?
I googled for some solutions and found INSERT IGNORE, ..ON DUPLICATE KEY UPDATE and REPLACE
in which I would have to inform the PK, but I don't know it (without using a extra query).