All Forums Database
Alsallam 9 posts Joined 04/15
05 Jun 2015
Concatenate using || causes null

I noticed that when I am using || to concatenate several fields, if one of them is null, the function returns null. Is there a way to return whatever values that are not null and ignor the null value?
for example:
select 'xyz-' || field1 || '=' || field2 '-' || field3 from tablename
 
if any of the fields is null, the returned results will be null. is there a function that would still return populated values?

dnoeth 4628 posts Joined 11/04
05 Jun 2015

This is Standard SQL behaviour, use COALESCE(field,'').

Dieter

Alsallam 9 posts Joined 04/15
08 Jun 2015

Thank you.

You must sign in to leave a comment.