Occasionally a field is blank but we have to sometimes have to show a default value or a value from another field. SQL gives us a nice tag to use:
isnull(field1, field2) as name or isnull(field1, 'n/a') as name
or we can use if/else logic this during output
<cfoutput>
<cfif #trim(field1)# eq ''>n/a or #field2##field1#
</cfoutput>
Notes:
data may contain multiple spaces so isNull may fail. try isNull(rtrim(field1), ‘/na’) or use #trim()# in the cfoutput logic.
isNull may have different syntax or may be ifNull in mySQL.
isNull can be used in sql statements where, and group by attributes without the “as fieldname” portion.