Skip to content

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

  • by

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

I spent 10 minutes to find the right 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


Hits: 31


Leave a Reply

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