Jump to content

Unique field value - but only if a value entered


murfitUK

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...