Let us consider a user table:
Username,email1,email2
Now, I want to make sure that no two rows in this table have any common email address. What would be the best way to ensure this ?
E.g.: If table has row: “Bill,bill@email.com,bill@gmail.com”, then
trying to insert a row like “Billy,billy@yahoo.com,bill@email.com” should give an error.
Thanks in advance,
Chandresh
Sadly,
checkconstraints are not a feature of MySQL. Well, they are, but they’re ignored.Use a
trigger, instead: