Jump to content

Unique field value - but only if a value entered


murfitUK
 Share

Recommended Posts

This related to MYSQL (not SQL).I have a table with a field called HBRef. This value can be null but if a value is entered it must be unique. In mysqladmin I have set the field's default value to null and the attribute to unique. Now I cannot enter a new record with HBRef as null because such a value already exists.How do I set it up so that the field HBRef has a unique value unless it is null?Thanks.

Edited by murfitUK
Link to comment
Share on other sites

You have to handle that melodramatically - although someone might know a little more about MySQL and therefore there could be away that I am not aware of to handle this strictly int he database (I'm not 100% sure). In code, though, you could write your insert/update queries several different ways to pull off the same end result.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...