This is what I\'m doing right now (name
is UNIQUE
):
SELECT * FROM fruits WHERE name=\'apple\';
Che
You can use the IGNORE feature:
INSERT IGNORE INTO fruits VALUES ('apple')
If there is a key violation, it just skips this value
check out
INSERT IGNORE INTO ...
and
INSERT ON DUPLICATE KEY UPDATE ...
Thes second method is preferred as the IGNORE statement simply causes mysql to issue warning instead of error