I challenged myself to write an SQL query so I can quickly export sets of subscribers to use in other outside services. I hope that this example code helps someone out there.

NOTES: Your mileage may vary with the SQL MD5 function depending on the character set of your database, but it checked out for me (MySQL 5.1). I'm sure some of this could be improved. Replace the obvious example parts with your own values/names. Add WHERE clause expressions as needed (or remove them for more results).

SET @simplenews_private_key=(SELECT LEFT(RIGHT(`value`, 34), 32) FROM `example_database`.`variable` WHERE `name` = 'simplenews_private_key' LIMIT 0,1); 
SELECT ss.mail, CONVERT(CONCAT('http://www.example.com/newsletter/confirm/remove/', LEFT(MD5(CONCAT(ss.mail, @simplenews_private_key)), 10), ss.snid, 't', sst.tid), CHAR(256/*set to max url length*/)) as `hash`
FROM `example_database`.`simplenews_subscriptions` ss
INNER JOIN `example_database`.`simplenews_snid_tid` sst ON ss.snid = sst.snid
WHERE sst.status = 1
ORDER BY ss.mail ASC;

Comments

simon georges’s picture

Status: Active » Fixed

So this is in fact not a request ;-)
Thanks for the snippet, it could be useful!

Automatically closed -- issue fixed for 2 weeks with no activity.