For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > July 2007 > Newbie question about UNIQUE MySQL v5.0.22









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 Newbie question about UNIQUE MySQL v5.0.22
nelson.salvador@gmail.com

2007-07-14, 7:01 pm

Hi all,

I need some help...

My Example:

Field: Bank Account N=BA: 12353545456

Field: Bank Account N=BA:

The n=BA must be unique but could be empty also...

What is the SQL? It's Possible?


Best Regards
PiRiCa

Ciaran

2007-07-22, 8:01 am

On Jul 15, 12:54 am, "nelson.salva...@gmail.com"
<nelson.salva...@gmail.com> wrote:
> My Example:
> Field: Bank Account N=BA: 12353545456
> Field: Bank Account N=BA:
>
> The n=BA must be unique but could be empty also...


If you introduce a UNIQUE constraint on a VARCHAR field, there can
only be one row that has the empty string ("") as its value.

However, if you allow the column to be NULL, you can insert as many
NULL records as you like.

-Ciaran McNulty

Sponsored Links







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

Copyright 2008 codecomments.com