While building my application with relational tables I ran into the following problem :
I have the following table, for this example named "valores":
-----------------------
| id | value |
-----------------------
| 1 | Unique VAL |
| 2 | Unique VAL2 |
-----------------------
ID = AUTOINCREMENT
VALUE = UNIQUE
What I'm trying to do is insert the a NEW value if it doesn't exist already, the way I'm doing it right now is:
INSERT IGNORE INTO valores (id, value) VALUES (NULL, "Unique VAL2");
So it won't do anything. Because the value already exists.. now my question is:
¿Is this the best and the fastest way to do it?