I would like to prevent duplication of records in my table. Using the UNIQUE keyword when creating a table is likely the best thing to do.
When attempting to insert a duplicate record, how do I get the KEY value of the record which previously exists in the table and is a duplicate of the record I am attempting to insert?
eg.
unique(name, comment)
private_key_id name comment
1 'bob' 'hello'
attempt to insert ('bob', 'hello') should be prevented but I should ALSO get the private_key_id --- 1 --- which it is attempting to duplicate.