mysql 更改列中的所有值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15430009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql change all values in a column
提问by StandardNerd
I want to change all values in the tablecolumn "Quellendatum".
我想更改表列“Quellendatum”中的所有值。
When the row-value is 2005-06-20 then it should be replaced with 2012-06-20. When the row-value is NULL or empty, then it should be untouched.
当行值为 2005-06-20 时,应将其替换为 2012-06-20。当 row-value 为 NULL 或为空时,它应该保持不变。
Currently i modify this manually by selecting the row:
目前我通过选择行手动修改它:
UPDATE `outgoing2`.`tbl_hochschule`
SET `Quellendatum` = '2012-06-20'
WHERE `tbl_hochschule`.`id` =1;
Is there a way to automate this task?
有没有办法自动化这个任务?
采纳答案by ethrbunny
How about:
怎么样:
UPDATE outgoing2.tbl_hochschule
SET Quellendatum = '2012-06-20'
WHERE Quellendatum = '2005-06-20'
AND !isnull( Quellendatum );
回答by LucianoDemuru
In MySql you can do:
在 MySql 中,您可以执行以下操作:
UPDATE TABLENAME
SET IDCOLUMN=VALUE
WHERE IDCOLUMN=VALUE
AND !isnull (IDCOLUMN)
回答by Devang Rathod
it should be :
它应该是 :
UPDATE tablename
SET Quellendatum = '2012-06-20'
WHERE Quellendatum = '2005-06-20'
回答by Kautil
UPDATE outgoing2.tbl_hochschule
SET Quellendatum = '2012-06-20'
WHERE Quellendatum <> '' AND Quellendatum <> NULL;