Find newsletter subscribers that are not in the UK

Open to all! Ask other shopowners for help.
Post Reply
14Steve14
Senior Contributor
Posts: 921
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Find newsletter subscribers that are not in the UK

Post by 14Steve14 »

My mailing list is getting to the limit of the free subscribers allowed so I need to trim the list somehow. I have already got all the non openers and non readers from the system available at Mailchimp.

I need some sql code that will produce a list of customers that are newsletter subscribers, but do not live in the UK. All I really need are their names and email addresses. I need to export the data into a spreadsheet so over time they can be unsubscribed after checking that they are also unsubscribed in the mailing list data. NOTE I do not want to directly delete them from the database.

Is this even possible.


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Find newsletter subscribers that are not in the UK

Post by ecartz »

Code: Select all

SELECT CONCAT_WS(' ', c.customers_firstname, c.customers_lastname) AS name, c.customers_email_address
 FROM customers c INNER JOIN address_book ab ON c.customers_id = ab.customers_id AND c.customers_default_address_id = ab.address_book_id
 WHERE c.customers_newsletter = '1' AND ab.entry_country_id != 222
14Steve14
Senior Contributor
Posts: 921
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Find newsletter subscribers that are not in the UK

Post by 14Steve14 »

ecartz wrote: Sat Mar 20, 2021 11:01 am

Code: Select all

SELECT CONCAT_WS(' ', c.customers_firstname, c.customers_lastname) AS name, c.customers_email_address
 FROM customers c INNER JOIN address_book ab ON c.customers_id = ab.customers_id AND c.customers_default_address_id = ab.address_book_id
 WHERE c.customers_newsletter = '1' AND ab.entry_country_id != 222
ecartz Many thanks. Worked like a charm. Have saved it somewhere half save for future use.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply