Concat and insert if not blank
Posted on 2014-01-27
I have the following which works fine
INSERT INTO product_images (product_image_name,sku)
select concat_ws(';',image1,image2,image3),item from import
ON DUPLICATE KEY UPDATE product_image_name=concat_ws(';',image1,image2,image3)
But I want to add some conditions:
If either image1,image2 or image3 is blank (will be blank and not NULL) then don't include that particular field.
If all fields are blank then skip
Is it possible? Would this make the sql very complicated? I can live with inserting 'blank' fields (as I will just do a delete on them) but would really like the empty fields to be skipped.