SQL Basic #2 : How to update a table with values from another table
Disclaimer : This tutorial is meant for beginners and for anyone who find it useful. The main purpose of this post to keep everything i find useful for future reference for myself and for others.
Update statement one of most common statement in developers daily routine but sometimes you will come across situation where you need update certain fields a table with values from other tables. Recently i came across this situation so i decided to share the sql statement with others throught this blog.
Example
I will update unitprice field of salesorderdetail table with the value of listprice field from product table using inner join where product.productid=salesorderdetail.productid, this is how the statement look like
update salesorderdetail set unitprice=product.listprice from salesorderdetail inner join product on salesorderdetail.productid=product.productid

I am an organism that turns coffee into software 

No responses to "SQL Basic #2 : How to update a table with values from another table"
No comments yet.
Leave a comment