Skip to content

Instantly share code, notes, and snippets.

@redsquirrel
Created November 10, 2008 21:48
Show Gist options
  • Select an option

  • Save redsquirrel/23648 to your computer and use it in GitHub Desktop.

Select an option

Save redsquirrel/23648 to your computer and use it in GitHub Desktop.
INSERT
INTO promotion_attempts (audience_member_id, state, mailing_id)
SELECT memberships.audience_member_id, 'ignorant', 18591
FROM memberships
INNER JOIN audience_members ON memberships.audience_member_id = audience_members.id
WHERE memberships.audience_list_id IN (7310)
AND (audience_members.suppressed IS NULL OR audience_members.suppressed = 0)
AND audience_members.email NOT IN (
SELECT promotion_attempts.email
FROM promotion_attempts
INNER JOIN mailings ON mailings.id = promotion_attempts.mailing_id
WHERE mailings.promotion_id = 10476 AND promotion_attempts.state != 'ignorant'
AND promotion_attempts.email IS NOT NULL
) ON DUPLICATE KEY UPDATE state='ignorant'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment