i have two tables in mysql . i want to add or subtract values from one table from another. i expect clear answer. please help me
A:
You can use UDPDATE JOIN.
Example:
IF there is a PK->FK relationship:
UPDATE table1 t1 inner join table2 t2 on t1.id = t2.id set t1.col1 = t1.col1+t2.coln;
other wise:
UPDATE table1 t1 cross join table2 t2 set t1.col1 = t1.col1+t2.coln where some condition;
Hope this will help you.
Sadat
2010-07-21 11:31:33