Jump to content

QUICKIE: Null versus Blank?


webmaster1

Recommended Posts

Hi All,

 

I'm using a basic select query puts in a default value if null is returned:

 

SELECT masterdataid, 
IFNULL(resultsnotations.prospectrating, 'Not Rated') AS prospectratingch, 
IFNULL(resultsnotations.lastactivity, 'Loaded') AS lastactivity
FROM resultsnotations
WHERE masterdataid = '339' and prospectrating is null
ORDER BY resultsnotations.lastactivity DESC 

 

For some reason when I output the row the default value doesn't show.

Furthermore when I query for rows will null I can't find any.

 

Am I confusing terminologies here? Is there a difference between NULL and BLANK?

 

Link to comment
Share on other sites

exactly as typed:

SELECT masterdataid,
IFNULL(resultsnotations.prospectrating, 'Not Rated') AS prospectratingch,
IFNULL(resultsnotations.lastactivity, 'Loaded') AS lastactivity
FROM resultsnotations
WHERE masterdataid = '339' and (prospectrating is null OR prospectrating = '')
ORDER BY resultsnotations.lastactivity DESC 

Link to comment
Share on other sites

null and the empty string are two totally different things. null is essentially undefined, not set, nothing, etc.  the empty string is something - it's a string with a length of zero.

 

Thanks for the run-through. Any ideas on how I check for string length using the IFNULL as well?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.