-1

I've got to delete about 10 email addresses from a huge database, wanted to find out the correct way to delete multiple emails from the db at once. I can delete one by one, just wondered if it was separating them by commas which I now need.

I presumed this is the appropriate SQL Statement:

DELETE FROM `subscribers` 
WHERE email='example1@example.com,example2@example.com,example3@example.com'

Is this the correct way to list multiple emails in order for them to be deleted from the database?

juergen d
  • 201,996
  • 37
  • 293
  • 362
wharfdale
  • 1,148
  • 6
  • 23
  • 53

2 Answers2

4

Use IN() and put the emails in quotes

DELETE FROM `subscribers` 
WHERE email IN('example1@example.com','example2@example.com','example3@example.com')
juergen d
  • 201,996
  • 37
  • 293
  • 362
2

Instead of =, use IN. E.g.

DELETE FROM subscribers 

WHERE email IN ('example1@example.com','example2@example.com','example3@example.com')
faintsignal
  • 1,828
  • 3
  • 22
  • 30