Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: Multiply all the values in a row by 2

Tags:

sql

mysql

I have a table Person with age as one of the columns having 1000 entries. I want to update age of each person my multiplying it by 2.

Would it be possible in one SQL query? I am using MySQL database.

like image 588
sachinpkale Avatar asked Jan 02 '13 11:01

sachinpkale


1 Answers

Yes, this is possible like so:

UPDATE Persons p
SET p.Age = p.Age * 2;
like image 122
Mahmoud Gamal Avatar answered Sep 18 '22 03:09

Mahmoud Gamal