Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将我的数据库中的两个数值(STOCKVOLUME 和 UNITS)加在一起,并将结果插入到列中的不同字段(NEWVAL)中。我希望这段代码对数据库中的每一行都执行此操作。
我怎样才能做到这一点?
UPDATE YourTable SET NEWVAL = STOCKVOLUME + UNITS
如果要插入另一个表:
INSERT INTO aTable(NEWVAL) SELECT (STOCKVOLUME + UNITS) FROM anotherTAble;
如果要更新同一张表的另一个字段:
UPDATE aTable SET NEWVAL = (STOCKVOLUME + UNITS);