Update one column as sum of other two columns Update one column as sum of other two columns sql sql

Update one column as sum of other two columns


There's no need for loops or inner selects. Just try this:

UPDATE table1 SET column1 = column1 + column2


It's allowed to read from columns in the set clause:

UPDATE  table1 SET     column1 = column1 + column2WHERE   rowid = 1


For all the rows you need not WHERE predicate:

UPDATE table SET  column1 = column1+column2

thats all.