I have a web app front end that uses nodeJS to facilitate connections and operations on a MySQL backend. I am looking for a way to implement a unique insert that returns an error message if it finds a duplicate key. Is there something I can implement along the lines of:
INSERT INTO clients set ? ON DUPLICATE KEY //SELECT "Error: Duplicate Entry"
AS "";
From there, what is the best way to retrieve this message and return it to the user on the web front end?