Jump to content

Unique field value - but only if a value entered

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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...