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? 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 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? 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 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? 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. Link to comment https://forums.phpfreaks.com/topic/190508-unique-yet-zeros-okay/#findComment-1004986 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.