List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:April 5 2003 5:07pm
Subject:Re: Not Null isn't working or am I wrong
View as plain text  
At 16:23 -0500 4/4/03, <mapainter@stripped> wrote:
>Hi everyone,
>      When creating a table I have a autonumber primary key, a 
>varchar(30) field that is not null and another field that not null 
>is not selected.  Here is the table creation command i used.
>
>CREATE TABLE `TableName` (`ID` INT (3) UNSIGNED DEFAULT '0' NOT NULL 
>AUTO_INCREMENT, `name` VARCHAR (30) NOT NULL, `place` CHAR (30), 
>PRIMARY KEY(`ID`), UNIQUE(`ID`), INDEX(`ID`));
>
>Now when i put data into the table i can't have all blanks which is 
>right.  When i put data into the field that allows nulls the not 
>null one gets '' as its data and goes on.  I though NULL and '' were 
>the same thing.  Am i nuts?

I don't know if you're nuts or not, but NULL and the empty string are
very definitely not the same thing.

>
>INSERT INTO TableName (ID, name, place) VALUES (NULL, NULL, NULL);
>gives me and error which is what I want
>
>but
>INSERT INTO TableName (ID, name, place) VALUES (NULL, '', NULL);
>
>goes without any problem and i thought it should return and error also

It won't, because '' is different than NULL.

>
>
>       thanks for any help or comments
>
>                     ,Michael


-- 
Paul DuBois
http://www.kitebird.com/
sql, query
Thread
Not Null isn't working or am I wrongmapainter5 Apr
  • Re: Not Null isn't working or am I wrongPaul DuBois5 Apr
    • Re: Not Null isn't working or am I wrongBruce Feist6 Apr
  • Re: Not Null isn't working or am I wronggerald_clark7 Apr