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
https://forums.phpfreaks.com/topic/155106-quickie-null-versus-blank/
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 

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.