For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > September 2007 > Unique constraint for the columns does not work when one of values is null.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Unique constraint for the columns does not work when one of values is null.
Pugi!

2007-09-14, 8:01 am

I have a table with a unique constraint on two integer columns.
Works fine, but one of the two columns can be null and then the
constraint does not work.
1 2 : OK
1 3 : OK
1 2 : error
2 null : OK
2 null : OK -> I want this to result in an error

Pugi!

Captain Paralytic

2007-09-14, 7:02 pm

On 14 Sep, 11:55, Pugi! <pugin...@gmail.com> wrote:
> I have a table with a unique constraint on two integer columns.
> Works fine, but one of the two columns can be null and then the
> constraint does not work.
> 1 2 : OK
> 1 3 : OK
> 1 2 : error
> 2 null : OK
> 2 null : OK -> I want this to result in an error
>
> Pugi!


Do not multi-post. Cross-post if you must but don't multi post It
wastes
people's time. http://www.blakjak.demon.co.uk/mul_crss.htm

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com