I’m trying to add link to my image when I return it from database but I don’t want to add it when image is null. I tried CONCAT and CONCAT_WS but it didn’t work
both of these didn’t work:
SELECT id, name_en as name, CONCAT_WS("http://website.com/", image) as image FROM businesses
SELECT id, name_en as name, CONCAT("http://website.com/", image) as image FROM businesses
>Solution :
you can use ÌF flowcoltrol,`to determine iif image is NULL and if not add the url
SELECT id, name_en as name, IF(image IS NOT NULL, CONCAT("http://website.com/", image),"") as image
FROM businesses