I have elaborated further the query in order to include all email addresses in one semi-colon separated field.
This is the query:
select accounts.*, accounts_cstm.*, GROUP_CONCAT(email_addresses.email_address SEPARATOR ';') AS all_email_addresses from accounts
inner join accounts_cstm on accounts.id = accounts_cstm.id_c
inner join email_addr_bean_rel on email_addr_bean_rel.bean_id = accounts.id
inner join email_addresses on email_addr_bean_rel.email_address_id = email_addresses.id
GROUP BY accounts.id
So, to get your csv file:
select accounts.*, accounts_cstm.*, GROUP_CONCAT(email_addresses.email_address SEPARATOR ';') AS all_email_addresses from accounts
inner join accounts_cstm on accounts.id = accounts_cstm.id_c
inner join email_addr_bean_rel on email_addr_bean_rel.bean_id = accounts.id
inner join email_addresses on email_addr_bean_rel.email_address_id = email_addresses.id
GROUP BY accounts.id
INTO OUTFILE 'c:/accounts_with_emails.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
With the following query, in addition to all emails you also get opt_out and invalid_email in:
select accounts.*, accounts_cstm.*, GROUP_CONCAT(CONCAT(email_addresses.email_address, ':', email_addresses.invalid_email, ':', email_addresses.opt_out) SEPARATOR ';') AS all_email_addresses from accounts
inner join accounts_cstm on accounts.id = accounts_cstm.id_c
inner join email_addr_bean_rel on email_addr_bean_rel.bean_id = accounts.id
inner join email_addresses on email_addr_bean_rel.email_address_id = email_addresses.id
GROUP BY accounts.id
(just replace the part before INTO to have the results in the file)
NOTE:
phpMyAdmin will say that 0 lines have been processed but you will get the full result in the file c:/accounts_with_emails.csv
If you elaborate further the query you can include more information on the email addresses (eg primary vs secondary) or, going even further, more information from other relationships.
PS: I haven’t tested thoroughly these queries, but they seemed to work fine. I recommend that you test them before relying on them!