DROP PROCEDURE IF EXISTS `add_image_to_product_category`; CREATE PROCEDURE `add_image_to_product_category`(pId INT, pLink VARCHAR(255)) begin declare tmpId int default null; SELECT pc.category_id INTO tmpId FROM products_category as pc where pc.category_id = pId; if tmpId is not null then UPDATE products_category SET `image_url` = pLink WHERE category_id = tmpId; end if; END;