Unix Technical Forum

null is not null

This is a discussion on null is not null within the MySQL forums, part of the Database Server Software category; --> Sorry if I missed a post about this before. Can someone explain this to me: mysql> select title from ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2008, 06:09 AM
ryan@goanimate.com
 
Posts: n/a
Default null is not null

Sorry if I missed a post about this before. Can someone explain this
to me:

mysql> select title from movie where id = 53259;
+-------+
| title |
+-------+
| NULL |
+-------+
1 row in set (0.00 sec)

mysql> select title from movie where id = 53259 and title is null;
Empty set (0.00 sec)

mysql> select length(title) from movie where id = 53259;
+---------------+
| length(title) |
+---------------+
| 0 |
+---------------+
1 row in set (0.00 sec)

mysql> select length(null) from movie where id = 53259;
+--------------+
| length(null) |
+--------------+
| NULL |
+--------------+
1 row in set (0.00 sec)

As far as I can tell, this column is not NULL, and is not 'NULL'. What
is it?

Thanks for your help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-24-2008, 06:09 AM
Captain Paralytic
 
Posts: n/a
Default Re: null is not null

On 21 May, 04:18, r...@goanimate.com wrote:
> Sorry if I missed a post about this before. Can someone explain this
> to me:
>
> mysql> select title from movie where id = 53259;
> +-------+
> | title |
> +-------+
> | NULL |
> +-------+
> 1 row in set (0.00 sec)
>
> mysql> select title from movie where id = 53259 and title is null;
> Empty set (0.00 sec)
>
> mysql> select length(title) from movie where id = 53259;
> +---------------+
> | length(title) |
> +---------------+
> | 0 |
> +---------------+
> 1 row in set (0.00 sec)
>
> mysql> select length(null) from movie where id = 53259;
> +--------------+
> | length(null) |
> +--------------+
> | NULL |
> +--------------+
> 1 row in set (0.00 sec)
>
> As far as I can tell, this column is not NULL, and is not 'NULL'. What
> is it?
>
> Thanks for your help.


Please export the CREATE TABLE statement and a sample of the data (as
an INSERT statement) which includes this record and post it here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-24-2008, 06:09 AM
motion musso: aka sathia
 
Posts: n/a
Default Re: null is not null

ryan@goanimate.com wrote:

> select title from movie where id = 53259 and title is null;


try

select title from movie where id = 53259 and title = 'NULL';

probably it has been inserted as string
happened to me once.

--
e ziocan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-24-2008, 06:09 AM
Captain Paralytic
 
Posts: n/a
Default Re: null is not null

On 21 May, 11:54, "motion musso: aka sathia" <sathia.mu...@libero.it>
wrote:
> r...@goanimate.com wrote:
> > select title from movie where id = 53259 and title is null;

>
> try
>
> select title from movie where id = 53259 and title = 'NULL';
>
> probably it has been inserted as string
> happened to me once.

If it was a string,
mysql> select length(title) from movie where id = 53259;

Would have produced he answer 4 and not:
+---------------+
| length(title) |
+---------------+
| 0 |
+---------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-24-2008, 06:10 AM
ryan@goanimate.com
 
Posts: n/a
Default Re: null is not null

On May 21, 5:17*pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> Please export the CREATE TABLE statement and a sample of the data (as
> an INSERT statement) which includes this record and post it here.


Thanks, Captain Paralytic. From the export, it looks like an empty
string:

CREATE TABLE `movie` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`user_id` int(11) NOT NULL default '0',
`domain_id` varchar(20) NOT NULL default '',
`title` varchar(50) default '',
...
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `movie` VALUES (53248,131012,'804','','','<xml...

~rvr
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-24-2008, 06:10 AM
Rik Wasmus
 
Posts: n/a
Default Re: null is not null

ryan@goanimate.com wrote:
> On May 21, 5:17 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>> Please export the CREATE TABLE statement and a sample of the data (as
>> an INSERT statement) which includes this record and post it here.

>
> Thanks, Captain Paralytic. From the export, it looks like an empty
> string:
>
> CREATE TABLE `movie` (
> `id` bigint(20) unsigned NOT NULL auto_increment,
> `user_id` int(11) NOT NULL default '0',
> `domain_id` varchar(20) NOT NULL default '',
> `title` varchar(50) default '',
> ...
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
>
> INSERT INTO `movie` VALUES (53248,131012,'804','','','<xml...


53248 != 53259
We're actually only interested in that record that misbehaves. From the
create syntax we know it's actually a table (not a view with possible
side effects for instance), and that NULLs are allowed.
--
Rik Wasmus
....spamrun finished
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-24-2008, 06:10 AM
Captain Paralytic
 
Posts: n/a
Default Re: null is not null

On 22 May, 14:27, r...@goanimate.com wrote:
> On May 21, 5:17 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
> > Please export the CREATE TABLE statement and a sample of the data (as
> > an INSERT statement) which includes this record and post it here.

>
> Thanks, Captain Paralytic. From the export, it looks like an empty
> string:
>
> CREATE TABLE `movie` (
> `id` bigint(20) unsigned NOT NULL auto_increment,
> `user_id` int(11) NOT NULL default '0',
> `domain_id` varchar(20) NOT NULL default '',
> `title` varchar(50) default '',
> ...
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
>
> INSERT INTO `movie` VALUES (53248,131012,'804','','','<xml...
>
> ~rvr


My instructions were:
Please export the CREATE TABLE statement and a sample of the data (as
an INSERT statement) which includes this record and post it here.

Note the "which includes this record" bit!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:31 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com