Skip to content
Advertisement

mysql change all values in a column

I want to change all values in the tablecolumn “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.

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?

Advertisement

Answer

How about:

UPDATE outgoing2.tbl_hochschule 
SET Quellendatum = '2012-06-20' 
WHERE Quellendatum = '2005-06-20' 
AND !isnull( Quellendatum );
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement