Bluehost.com Web Hosting $6.95

SELECT RECORD WHERE COLUMN IS NULL

This is a discussion on SELECT RECORD WHERE COLUMN IS NULL within the MySQL Database forums, part of the Database Forums category; I have a column defined as VARCHAR 40 NULL I trying to select records where this column is NULL (or ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2007
Josselin
 
Posts: n/a
Default SELECT RECORD WHERE COLUMN IS NULL

I have a column defined as VARCHAR 40 NULL

I trying to select records where this column is NULL (or no active_code) using

WHERE relationships.befriender_id = 22 AND relationships.active_code = NULL

but I don' t get it

WHERE relationships.befriender_id = 22 works fine

I am wrong but why ?

thanks fyl

joss

Reply With Quote
  #2 (permalink)  
Old 02-28-2007
strawberry
 
Posts: n/a
Default Re: SELECT RECORD WHERE COLUMN IS NULL

On Feb 28, 10:37 pm, Josselin <josse...@wanadoo.fr> wrote:
> I have a column defined as VARCHAR 40 NULL
>
> I trying to select records where this column is NULL (or no active_code) using
>
> WHERE relationships.befriender_id = 22 AND relationships.active_code = NULL
>
> but I don' t get it
>
> WHERE relationships.befriender_id = 22 works fine
>
> I am wrong but why ?
>
> thanks fyl
>
> joss


WHERE field IS NULL
or
WHERE ISNULL(field)

Reply With Quote
  #3 (permalink)  
Old 02-28-2007
Lee Peedin
 
Posts: n/a
Default Re: SELECT RECORD WHERE COLUMN IS NULL

On Wed, 28 Feb 2007 23:37:36 +0100, Josselin <josselin@wanadoo.fr>
wrote:

>I have a column defined as VARCHAR 40 NULL
>
>I trying to select records where this column is NULL (or no active_code) using
>
>WHERE relationships.befriender_id = 22 AND relationships.active_code = NULL
>
>but I don' t get it
>
>WHERE relationships.befriender_id = 22 works fine
>
>I am wrong but why ?
>
>thanks fyl
>
>joss



Try
is NULL vs. = NULL
Reply With Quote
  #4 (permalink)  
Old 03-01-2007
Michael Austin
 
Posts: n/a
Default Re: SELECT RECORD WHERE COLUMN IS NULL

strawberry wrote:
> On Feb 28, 10:37 pm, Josselin <josse...@wanadoo.fr> wrote:
>
>>I have a column defined as VARCHAR 40 NULL
>>
>>I trying to select records where this column is NULL (or no active_code) using
>>
>>WHERE relationships.befriender_id = 22 AND relationships.active_code = NULL
>>
>>but I don' t get it
>>
>>WHERE relationships.befriender_id = 22 works fine
>>
>>I am wrong but why ?
>>
>>thanks fyl
>>
>>joss

>
>
> WHERE field IS NULL
> or
> WHERE ISNULL(field)
>



The reason is the fact that NULL does not equal anything -
in fact NULL != NULL so you must use the database syntax previously stated.

M.
Reply With Quote
  #5 (permalink)  
Old 03-01-2007
Josselin
 
Posts: n/a
Default Re: SELECT RECORD WHERE COLUMN IS NULL

On 2007-02-28 23:37:36 +0100, Josselin <josselin@wanadoo.fr> said:

> I have a column defined as VARCHAR 40 NULL
>
> I trying to select records where this column is NULL (or no active_code) using
>
> WHERE relationships.befriender_id = 22 AND relationships.active_code = NULL
>
> but I don' t get it
>
> WHERE relationships.befriender_id = 22 works fine
>
> I am wrong but why ?
>
> thanks fyl
>
> joss


thanks to all of u... got it sosimple :-()

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:26 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0