Skip to content

How to update value in DB table only when the cell is not empty or null (MySQL)

I faced the problem I only needed to update the data fields with values. When you work with a real app that has a working send email module you don’t want to bother the clients. Just change their email with yours

I spent 10 minutes trying to find the correct query :)

Here it is:

UPDATE USERS SET `email` = CASE WHEN `email`='' or `email` IS NULL THEN "" ELSE "<change>@<address>.com" END;

Don’t forget to change the email address

Views: 33

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *