Hi, I need to drop tables from a database where all the email addresses end in the same domain,
ie, say I have 1000 email addresses i need to input an MYSQL query to delete all rows containing email addresses ending with @mydomain.co.uk.

Does anyone know how to do this?

DELETE FROM yourtable WHERE emailcolumn LIKE '%@mydomain.co.uk'
Member Avatar for diafol

WHy do you need to drop a table? It sounds like you just need to delete records from that table. For deleting specific email address domains:

DELETE FROM `mytable` WHERE `email` LIKE '%@mydomain.co.uk'

If you do this, then remember if you have any related records in other tables that these are also deleted - use CASCADE:

http://www.mysqltutorial.org/mysql-on-delete-cascade/

//EDIT - prit - was writing as you posted, heh heh.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.