I'm trying to define a unique constraint in MySQL that will treat NULLs as non-distinct to each other.
I.e.
If I have a table like this:
column1 int(11) NOT NULL,
column2 int(11) DEFAULT NULL
whose values are populated by AUTO INCREMENT INT, and then define a unique constraint as follows:
UNIQUE KEY uniq1 (column1, column2),
I can insert (1, NULL) multiple times because of MySQLs behaviour to treat NULLs as distinct to each other in a unique constraint. If however I actually wanted to prevent such duplicate insertion, is there a way other than assigning a magic value?