Created
July 9, 2014 02:38
-
-
Save samitny/ce97e871499017b0297c to your computer and use it in GitHub Desktop.
INSERT INTO campaigns_activities from activity where activity type is "subscriber" and action is "unsubscribe". (This is for a specific campaign ID which makes the join with "email_messages" pointless.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO campaigns_activities ( | |
SELECT | |
a.createdAt, | |
a.updatedAt, | |
a.id, | |
e.campaignId | |
FROM | |
activities a | |
LEFT JOIN | |
subscribers s ON (s.uuid = a.target) | |
LEFT JOIN | |
email_messages e ON (e.subscriberId = s.id AND e.`type` = 'bulk') | |
WHERE | |
a.type = 'subscriber' | |
AND | |
a.action = 'unsubscribe' | |
AND | |
e.campaignId = 4 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment