Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a table with data from another table

Status
Not open for further replies.

Timcwilcox

Programmer
Jun 28, 2002
12
GB
Please forgive my ignorance, but can someone post a solution for a very simple problem for a Oracle sql newbie.

I have a transaction table (call it stock_trans) and a stock master table (call is stock) and one of the fields on the stock transaction table is a cost price. Is there a sql script to populate the cost price on stock trans with the cost price from stock master.

Thanks in advance

Tim
 
If you are wanting to create a new row in stock_trans it could look like this:


insert into stock_trans (cost_price, other_columns)
select cost_price, other_values
from stock
where whatever;

If you are wanting to update a row in stock_trans:

update stock_trans
set cost_price = (select cost_price
from stock
where whatever)
where whatever;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top