sql - How do I update a column in all rows of a table based on values in other columns (for the same row)? -
i apologize in advance if sql doesn't work way, code in c++/c# , don't have experience in sql. want iterate through each row of table , change column value based on other columns. example table might this:
__________________________ |first #|second #|third #| |_______|________|_______| |___1___|___1____|___0___| |___5___|___2____|___0___| |___3___|___6____|___0___| |___2___|___4____|___0___| now, in pseudo code, trying equivalent of:
foreach row in mytable, column 3 = column 1 + column 2 what way sql equivalent of this, or can not done in way?
this simple this,
update tablename set thirdcol = firstcol + secondcol
Comments
Post a Comment