Skip to content

Instantly share code, notes, and snippets.

@sc0ttkclark
Created February 16, 2015 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sc0ttkclark/c8f8b4d009442057c896 to your computer and use it in GitHub Desktop.
Save sc0ttkclark/c8f8b4d009442057c896 to your computer and use it in GitHub Desktop.
Delete all GF lead data if lead has been deleted
DELETE
lead_detail
FROM
wp_rg_lead_detail AS lead_detail
LEFT JOIN
wp_rg_lead AS lead ON lead.id = lead_detail.lead_id
WHERE
lead.id IS NULL;
DELETE
lead_detail_long
FROM
wp_rg_lead_detail_long AS lead_detail_long
LEFT JOIN
wp_rg_lead_detail AS lead_detail ON lead_detail.id = lead_detail_long.lead_detail_id
WHERE
lead_detail.id IS NULL;
DELETE
lead_meta
FROM
wp_rg_lead_meta AS lead_meta
LEFT JOIN
wp_rg_lead AS lead ON lead.id = lead_meta.lead_id
WHERE
lead.id IS NULL;
DELETE
lead_notes
FROM
wp_rg_lead_notes AS lead_notes
LEFT JOIN
wp_rg_lead AS lead ON lead.id = lead_notes.lead_id
WHERE
lead.id IS NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment