mysql - How to handle null field value when using LIKE -
table data:
i have sql script:
select ei.objid entityindividual ei inner join entity e on ei.objid = e.objid left join entity_address ea on ei.objid = ea.parentid ei.gender = 'm' , isnull(ea.barangay_name) '%'
if run script, 6 records displayed, without using isnull(ea.barangay_name)
, 1 record diplayed.
but consider scenario:
select ei.objid entityindividual ei inner join entity e on ei.objid = e.objid left join entity_address ea on ei.objid = ea.parentid ei.gender = 'm' , isnull(ea.barangay_name) '%buenavista%'
the problem no records display when run script above. why? how fix one?
try using coalesce
instead of isnull
.
http://www.w3resource.com/mysql/comparision-functions-and-operators/coalesce-function.php
select ei.objid entityindividual ei inner join entity e on ei.objid = e.objid left join entity_address ea on ei.objid = ea.parentid ei.gender = 'm' , coalesce(ea.barangay_name,'') '%buenavista%'
Comments
Post a Comment