Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to create a table in MySQL that will have a Unique constrant...

Status
Not open for further replies.

lich12345

Programmer
Joined
Sep 27, 2001
Messages
1
Location
US
I want to create a table in MySQL that will have a Unique constrant, however I also want the option of putting in NULL. In other words when inserting data into this column it allows me to enter NULL or other then that it has to be unique data.

Help

Jeremy
 
Hi Jeremy,

I am sorry, but you cannot do this with RDBMS. Every value has to be unique, and NULL is a value of its own, so two NULLS will be a duplicate key failure. You can either make the column a Unique contraint, or a NULL, but they are mutually exclusive.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top