{"id":72,"date":"2010-05-07T13:39:23","date_gmt":"2010-05-07T17:39:23","guid":{"rendered":"http:\/\/erics-test-lab.com\/?p=72"},"modified":"2010-05-07T13:39:23","modified_gmt":"2010-05-07T17:39:23","slug":"isnull","status":"publish","type":"post","link":"https:\/\/www.esearing.com\/v2010\/2010\/05\/isnull\/","title":{"rendered":"isNull"},"content":{"rendered":"<p>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:<\/p>\n<p><code>isnull(field1, field2) as name  or  isnull(field1, 'n\/a') as name<\/code><\/p>\n<p>or we can use if\/else logic this during output<br \/>\n<code>&lt;cfoutput><br \/>\n&lt;cfif #trim(field1)# eq ''>n\/a or #field2#<\/cfelse>#field1#<\/cfif><br \/>\n&lt;\/cfoutput><\/code><\/p>\n<p><strong>Notes:<\/strong><br \/>\ndata may contain multiple spaces so isNull may fail. try isNull(rtrim(field1), &#8216;\/na&#8217;) or use #trim()# in the cfoutput logic.<br \/>\nisNull may have different syntax or may be ifNull in mySQL.<br \/>\nisNull can be used in sql statements  where, and  group by attributes without the &#8220;as fieldname&#8221; portion.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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, &#8216;n\/a&#8217;) as name or &hellip; <a href=\"https:\/\/www.esearing.com\/v2010\/2010\/05\/isnull\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,16,24,14],"tags":[],"class_list":["post-72","post","type-post","status-publish","format-standard","hentry","category-code","category-coldfusion","category-snippets-quick-code-tips-for-single-elements-attributes-or-details","category-sql"],"_links":{"self":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/comments?post=72"}],"version-history":[{"count":0,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/72\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/media?parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/categories?post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/tags?post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}