Reputation: 4183
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?
Upvotes: 34
Views: 118283
Reputation: 47
If Quellendatum = "2005-06-20" then it can't be NULL. So I don't see the use of ' AND !isnull (Quellendatum)
Upvotes: 0
Reputation: 19
You can try
UPDATE TABLE
SET COLUMN_NAME = " "
This will update all the values in a column
Upvotes: 0
Reputation: 131
In MySql you can do:
UPDATE TABLENAME
SET IDCOLUMN=VALUE
WHERE IDCOLUMN=VALUE
AND !isnull (IDCOLUMN)
Upvotes: 12
Reputation: 1331
UPDATE outgoing2.tbl_hochschule
SET Quellendatum = '2012-06-20'
WHERE Quellendatum <> '' AND Quellendatum <> NULL;
Upvotes: 0
Reputation: 6736
it should be :
UPDATE tablename
SET Quellendatum = '2012-06-20'
WHERE Quellendatum = '2005-06-20'
Upvotes: 6
Reputation: 10469
How about:
UPDATE outgoing2.tbl_hochschule
SET Quellendatum = '2012-06-20'
WHERE Quellendatum = '2005-06-20'
AND !isnull( Quellendatum );
Upvotes: 37