sql - How can I update the value of multiple rows to a different specified value in the same column? -
say have table there product ids, product desc., , language of each desc. if there description null value american-english, update british-english version of description product. there way using update command in sql?
i prefer syntax updating values in 1 table values in (or in case same) table, b/c easy change update...set
select
testing , see values updated.
update p_us set p_us.product_desc = p_gb.product_desc dbo.product p_us inner join dbo.product p_gb on p_us.productid = p_gb.productid p_us.language_code = 'us' , p_gb.language_code = 'gb' , p_us.product_desc null ;
and can swap out first 2 lines above quick testing see updated:
select p_us.productid, p_us.product, olddesc = p_us.product_desc, newdesc = p_gb.product_desc
Comments
Post a Comment