hmark Posted February 1, 2010 Share Posted February 1, 2010 I want to have a field that is unique, but allow zeros or nulls. Is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/190508-unique-yet-zeros-okay/ Share on other sites More sharing options...
kickstart Posted February 1, 2010 Share Posted February 1, 2010 Hi A unique key can't have duplicates of zero but can have duplicates of null. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/190508-unique-yet-zeros-okay/#findComment-1004883 Share on other sites More sharing options...
hmark Posted February 1, 2010 Author Share Posted February 1, 2010 I've set my column to varchar(15) unique and null to okay. Yet, when I try and enter a record with a null in this column, I get the following message "Duplicate entry '' for key 2"". What do you suggest? Quote Link to comment https://forums.phpfreaks.com/topic/190508-unique-yet-zeros-okay/#findComment-1004925 Share on other sites More sharing options...
kickstart Posted February 1, 2010 Share Posted February 1, 2010 Hi Should be OK (but not using BDB storage engine). Double check that the column is set as OK for nulls and doesn't have a default value. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/190508-unique-yet-zeros-okay/#findComment-1004939 Share on other sites More sharing options...
hmark Posted February 1, 2010 Author Share Posted February 1, 2010 My default is NULL. Is that okay? Quote Link to comment https://forums.phpfreaks.com/topic/190508-unique-yet-zeros-okay/#findComment-1004966 Share on other sites More sharing options...
fenway Posted February 1, 2010 Share Posted February 1, 2010 My default is NULL. Is that okay? Yes -- this is what kickstart just said. Quote Link to comment https://forums.phpfreaks.com/topic/190508-unique-yet-zeros-okay/#findComment-1004986 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.