If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > why NULL is not considered to be duplicate value ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-17-11, 06:47
bchanan bchanan is offline
Registered User
 
Join Date: Dec 2009
Posts: 27
why NULL is not considered to be duplicate value ?

Hello All,

I have created the following table:
CREATE TABLE `kuku` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(20) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
UNIQUE KEY `aaa` (`c`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

and tried:
insert into kuku values (1, 'aaaa', 1);
insert into kuku values (2, 'aaaa', 1); - alert with duplicate error message
insert into kuku values (3, 'aaaa', null);
insert into kuku values (4, 'aaaa', null); - no alert was found
Reply With Quote
  #2 (permalink)  
Old 02-17-11, 07:48
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
database - 0 , NULL, empty string, Default values - MySql Questions - Stack Overflow

NULL isn't a comparable value you have to use the specific verbs to look at nulls in MySQL or for that matter virtually every other database
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 03-14-11, 03:48
subhbwn subhbwn is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
NULL is not duplicate

Because mo two null values are equal.You can refer to MySql select with NULL value - MySQL tutorial | w3resource for learning NULL in detail.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On