StandardNerd StandardNerd - 1 year ago 126
MySQL Question

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?

Answer Source

How about:

UPDATE outgoing2.tbl_hochschule 
SET Quellendatum = '2012-06-20' 
WHERE Quellendatum = '2005-06-20' 
AND !isnull( Quellendatum );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download