Since you are using the MyISAM (or INNODB) storage engine, the short answer is no. A few empty lines will not work for a unique index constraint, at least a few zeros. Best of all, if you want to use only the SQL solution, it is to create a regular index in the ISBN field, and then use the stored procedure to work as a proxy proxy server that checks if it is unique, if not empty or empty.
If only zeros work for you, here is a basic creation:
CREATE TABLE `books` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `isbn` int(13) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `isbn` (`isbn`) )
Just a note ... Remember that the value "13" specified for int is only the number of digits that will be displayed when returning in the request, not the size of an integer.
source share