Configuring UNIQUE constraint in MYSQL to avoid duplicate entries for a given column/field
MySQL Query: ALTER TABLE `MyLabDB`.`testusers` DROP INDEX `username` , ADD UNIQUE `username` ( `username` ) COMMENT ‘Avoid duplicate entries for username’; phpMyAdmin GUI: After setting the Unique Index for the field, whenever a duplicate entry is attempted for insertion, mySQL will result in “#1062” error as shown below: #1062 – Duplicate entry ‘user9’ for key ‘username’ < p>
Read more