Skip to content

is it possible to do a conditional concat?

I have a query that pulls different data but for one field it concats its since the URL is partially filled in my db

select blah, blah2, blah3, concat('', g.logourl ) as logourl

but the problem is if logourl is blank then I just get instead of the full URL. This is having down stream impact.

Is there a way to only concat if logurl is not null?



You can try using case when expression

select blah, blah2, blah3, 
 case when g.logourl is not null and g.logourl<>''
     then concat('', g.logourl ) end as logourl
10 People found this is helpful