When the table ERRORMESSAGE contains no rows that satisfy the "WHERE" condition, IFNULL fails and I get null, not the default value provided in the IFNULL clause.
select IFNULL(errorCode , 'NOERRORCODE') as "errorCode",
IFNULL(errorText , 'NOERROR') as "errorText" from
(select errorcode,
IFNULL((select errorText from STATIC_ERRORCODES a
where a.errorcode = b.errorcode), '') as errorText
from ERRORMESSAGE b where b.route_id = 'IPN4'
order by b.row_index)
When there are no rows in ERRORMESSAGE with route_id = 'IPN4', the output should be:
errorCode = NOERRORCODE
errorText = NOERROR
But I get null/empty values. How can I resolve this?