bacterio of Engineering
5/5/2015 - 10:08 AM

Cambiar la marca de los productos asociados a los coupon_ids que se reciben como parámetros

Cambiar la marca de los productos asociados a los coupon_ids que se reciben como parámetros

-- if we want to change all products of a brand
update laboratory_products 
set laboratory_brand_id = 2148, 
    laboratory_id = 212, 
    updated_date = NOW() 
where laboratory_brand_id = 1253;
-- execute the update

update laboratory_products lp
inner join coupon_details cd using (laboratory_product_id)
set laboratory_brand_id = 2436, laboratory_id = 234, updated_date = NOW()
where cd.coupon_id in (25116,25117);

-- verify the update

select cd.coupon_id, lp.laboratory_product_id, 
lp.laboratory_brand_id, lp.laboratory_id 
from laboratory_products lp
inner join coupon_details cd using (laboratory_product_id)
where cd.coupon_id in (25116,25117);