Sai Sai - 1 year ago 91
SQL Question

How to update multiple values in one column using one sql query?

I am working with a huge user database and there are around 200 user emails I want to set to an empty value, is there a easy way to remove them all in one query? here is a simple idea of what the table looks like.

(also as there a lots of email, I dont want to looks for all the ids, i only have the emails to work with)

column1 | column2 | customerEmail | column4
1 email1
2 email2
3 email3

Here is what i was going for but i received syntax error when using it for multiple values.

UPDATE `email-database`
SET customerEmail = ''
WHERE customerEmail = '', '', '';

Answer Source

Use IN

UPDATE `email-database`
SET customerEmail = ''
WHERE customerEmail IN ( '', '', '')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download