"mysql falsely allowing duplicate entries when one of the fields involved is null" Code Answer

1

you can't compare null's (if you compare anything with null even null=null the results is always false) this behavior is documented in mysql ref.

a unique index creates a constraint such that all values in the index must be distinct. an error occurs if you try to add a new row with a key value that matches an existing row. for all engines, a unique index permits multiple null values for columns that can contain null.

so i think the only way is define columns not null or handle this issue in a trigger.

By Arthur Azevedo De Amorim on May 30 2022

Answers related to “mysql falsely allowing duplicate entries when one of the fields involved is null”

Only authorized users can answer the Search term. Please sign in first, or register a free account.