Question

In mysql database in user table. I have a field named age but now I would like to move all the contents of age field to newly created field named age_min. How can I do that? Thanks in advance..

Was it helpful?

Solution

You can try this

 UPDATE `user` SET age_min=age;

OTHER TIPS

Simply do:

Update table set age=age_min;

It will replicate the value of the field age to the field age_min

try this qry...

update `user` set `age_min` = `age`;

This Should do:

UPDATE user SET age_min = age;

You could copy all of the data to the new column:

UPDATE `user` SET `age_men` = `age`

OR you could just rename the existing column:

ALTER TABLE `user` CHANGE `age` `age_min` int

(you may have to drop the new column you just created in order to run the above query, if so, do this: ALTER TABLE user DROP age_min

SQL Fiddle:

http://sqlfiddle.com/#!2/dfe84/2

Run this query:

UPDATE `user` SET `age_min` = `age` 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top