i want try to update the value of record from table1 where the value i need is from table2


Item_id | Quantity
0001    | 100
0002    | 200
0003    | 300
Item_id | Quantity
0002    | 100
0003    | 50
when the query run.... i want the table1 shows
Item_id  | Quantity
0001     | 100
0002     | 300
0003     | 350

i tried every kind of way to do it...
but still can run it...

Recommended Answers

All 5 Replies

what exactly you tried ?

i tried to INNER JOIN the 2 table with added table1 quantity and table2 quantity,
then i tried to replace the added value to table1 quantity with UPDATE...
but it doesn't work

post your code here, will try to fix that.

r u saying the below kind of query is not working??

update t1
set t1.Quantity = t1.Quantity + t2.Quantity
from table1 t1
inner join table2 t2
on t1.Item_id = t2.Item_id

make a cursor and then select rows from table2 and then update one by one rows in table1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.