I want to add together two numerical values in my database (STOCKVOLUME and UNITS) and insert the result into a different field in a column (NEWVAL). I want this code to do this for every row in the database.
How can I do this?
UPDATE YourTable
SET NEWVAL = STOCKVOLUME + UNITS
If you want to insert into another table :
INSERT INTO aTable(NEWVAL) SELECT (STOCKVOLUME + UNITS) FROM anotherTAble;
If you want to Update another filed of the same table :
UPDATE aTable SET NEWVAL = (STOCKVOLUME + UNITS);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With