MySQL Forums
Forum List  »  General

Re: Update each row in a table based on value in column on same row
Posted by: Mike Hillyer
Date: January 11, 2005 12:44PM

First of all, why create a calculated column? It would be better to do the calculation during a SELECT to ensure that the values are always up-to-date.

In any case, when updating a column based on the value of another column, just do an UPDATE. Say columnB is columnA+5:

UPDATE mytable SET columnB = ColumnA + 5;

And every row is updated.

Mike Hillyer, Technical Writer
MySQL AB, www.mysql.com
Office: +1 403-380-6535
Mobile: +1 403-330-0870
Blog: http://www.openwin.org/mike

Options: ReplyQuote


Subject
Written By
Posted
Re: Update each row in a table based on value in column on same row
January 11, 2005 12:44PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.