两表连接查询,需要将其中一列的值加到另一列上(两列在分别两张表中);
update (select * from g3_buybudget,g3_budget_plan where g3_buybudget.budgetno
in (select budgetno from g3_budget_plan where buyplanno = 1031))
set remainingmoney = remainingmoney + thismoney
这些百度都有的。不会的可以先百度下
UPDATE table1 alias
SET (column_name,column_name ) = (
SELECT (column_name, column_name)
FROM table2
WHERE column_name = alias.column_name)
WHERE column_name = VALUE
update
set remainingmoney = remainingmoney + thismoney
这个错了
(select * from g3_buybudget,g3_budget_plan where g3_buybudget.budgetno
in (select budgetno from g3_budget_plan where buyplanno = 1031))
改成
budgetno in (select budgetno from g3_budget_plan where buyplanno = 1031))
最后
update 表名
set remainingmoney = remainingmoney + thismoney
where budgetno in (select budgetno from g3_budget_plan where buyplanno = 1031))