Reputation: 29
I have a user editing table in my admin page in my website. I want to check if theres a duplication with the username and the email when i update a row. Every row prefers to a different user and has her own id. I want that if in a certain row there a username and email values they cant be duplicated (every id has its own stats). How can i check the duplication ? (I work with myadohelper) Hope to a quick answer, thanks
Upvotes: 0
Views: 30
Reputation: 1269763
The best way to do this is by setting up a unique constraint/index in the database.
alter table t add constraint unq_t_username_email on t(username, email);
An attempt to add a row that already exists will result in an error.
Upvotes: 2