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..

有帮助吗?

解决方案

You can try this

 UPDATE `user` SET age_min=age;

其他提示

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` 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top