Newbie question about UNIQUE MySQL v5.0.22

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
nelson.salvador [ So, 15 Juli 2007 01:54 ] [ ID #1769291 ]

Re: Newbie question about UNIQUE MySQL v5.0.22

On Jul 15, 12:54 am, "nelson.salva... [at] gmail.com"
<nelson.salva... [at] 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
Ciaran Mcnulty [ So, 22 Juli 2007 13:04 ] [ ID #1775499 ]
PHP » alt.php.sql » Newbie question about UNIQUE MySQL v5.0.22

Vorheriges Thema: Dropping all tables in a database?
Nächstes Thema: rename all tables in database newbie question