简体   繁体   中英

How to scan for and export all email addresses from a MySQL database

I use Joomla 2.5 to run my website. I have the standard user accounts, but I also use 2 components SobiPro and Jevents that hold their own user data in their own tables in the MySQL database.

My client has asked me to add all the website users to their MailChimp list. I can do this by doing a csv import.

I can only find a way to export the sobipro_feild_data in its whole as a CSV file. This contains too much information, i'm having to manually search for email addresses using search & find and copy/paste them to a new csv file. This is taking me ages.

Surely there is a simple command I can use in PHPMyAdmin to scan the MySQL database for anything that looks like an email address and export them as a single list.

Is this possible? Can anyone tell me how to get all email addresses out of my MySQL database as a list with no other data?

_Ash.

You can use a regular expresion to identify the emails, like:

SELECT *
FROM users
WHERE email REGEXP '^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}$'

After that, you can export the values and organize them.

Update: you can look for better regular expresions to match emails on google.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM