sql server update batch update method

Suppose we have two tables, a table to store product information Product table with prices listed Price; another table is ProductPrice table, we want to ProductPrice table price fields updated Price Price Price field in the table 80%. 
In Mysql we have several means to do this, one is update table1 t1, table2 ts ... way: 

 
UPDATE product p, productPrice pp 
SET pp.price = pp.price * 0.8 
WHERE p.productId = pp.productId 
AND p.dateCreated < '2004-01-01' 

 


Another method is to use the inner join then update: 

 

UPDATE product p 
INNER JOIN productPrice pp 
ON p.productId = pp.productId 
SET pp.price = pp.price * 0.8 
WHERE p.dateCreated < '2004-01-01' 

 

Guess you like

Origin www.cnblogs.com/baili-luoyun/p/11163359.html
Recommended