I want that when you try to do an INSERT, but the value of a specific variable is already registered, it shows an error.
For example: | user | e-mail | | -------- | -------------- | | Joseph | [email protected] | | Rex | [email protected] |
If I enter this code it should show an error because the value is already assigned to a user.
INSERT INTO `users` (`usuario`, `email`) VALUES ("Eduardo", "[email protected]");
I hope I explained myself well, I'm new and this would help me a lot.
You can first request the registered data with SELECT and then compare the entered data with the registered data and thus if any of the entered data is repeated, show a message that the data already exists, and if not, save the data with INSERT , as I did next:
You can also do a SELECT with a WHERE to search directly for the data in the table:
Hope this can help you ;).