Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
-- Find suspect Memberships due to contributions being linked to multiple membership-payment records
SELECT AS mempay_id,
mempay.contribution_id AS contrib_id,
contrib.receive_date, contrib.total_amount,
mempay.membership_id AS mem_id,,
c_contrib.display_name AS contrib_contact_name, AS contrib_contact_id, AS mem_contact_id, c_mem.display_name AS mem_contact_name
civicrm_membership_payment mempay
LEFT JOIN civicrm_membership mem ON
LEFT JOIN civicrm_membership_type memtype ON
LEFT JOIN civicrm_contribution contrib ON
LEFT JOIN civicrm_contact c_mem ON
LEFT JOIN civicrm_contact c_contrib ON
WHERE mempay.contribution_id
IN ( SELECT contribution_id FROM civicrm_membership_payment GROUP BY contribution_id HAVING count(*)>1 )
ORDER BY contrib_id,

This comment has been minimized.

Copy link

@davejenx davejenx commented Nov 21, 2016

This will also show legitimate contributions where the contribution is for more than one membership.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.