List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 31 2002 4:53pm
Subject:Re: Bug in UNIQUE?
View as plain text  
At 16:49 +0000 1/31/02, Jude Insley wrote:
>Hi,
>
>The SQL below illustrates what I believe is a bug in MySQL up to and
>including 3.23.47. Essentially I need a unique key where one or more of
>the component fields of the unique key can be NULL. What seems to happen
>is that you can add "duplicate" rows if the value is NULL.

This is how UNIQUE indexes work in MySQL.  All values except NULL
must be unique.  If you use a PRIMARY KEY instead, this won't happen.
Of course, the reason it won't happen is that PRIMARY KEY disallows
NULL entirely.

Why does UNIQUE behave that way?  I suppose because NULL != NULL.

>
>Has anyone come across this before? Is this a bug?
>
>Thanks
>
>Jude Insley
>
>Wide Area Communications
>www.widearea.co.uk
Thread
Bug in UNIQUE?Unknown Sender31 Jan
  • Re: Bug in UNIQUE?Paul DuBois31 Jan
  • Re: Bug in UNIQUE?Carsten Gehling1 Feb
    • Re: Bug in UNIQUE?Dan Nelson1 Feb
      • RE: Bug in UNIQUE?J. Ceferino Ortega1 Feb