Skip to content

Instantly share code, notes, and snippets.

@mattm
Last active January 29, 2018 15:19
Show Gist options
  • Select an option

  • Save mattm/f9539fa26472bb2fc024002466092084 to your computer and use it in GitHub Desktop.

Select an option

Save mattm/f9539fa26472bb2fc024002466092084 to your computer and use it in GitHub Desktop.
Deleted Payment Records 2017+
SET @mpy_id = (SELECT MAX(mpy_id) + 1 from members_payments);
DROP TABLE IF EXISTS members_payments_all_ids;
CREATE TEMPORARY TABLE members_payments_all_ids AS (
SELECT @mpy_id := @mpy_id - 1 AS mpy_id
FROM members_payments mp1, members_payments mp2
WHERE @mpy_id > 1
);
SELECT members_payments_all_ids.mpy_id AS mpy_ids
FROM members_payments_all_ids
LEFT JOIN members_payments ON members_payments_all_ids.mpy_id = members_payments.mpy_id
WHERE
members_payments.mpy_id IS NULL AND
members_payments_all_ids.mpy_id >= 162396
ORDER BY members_payments_all_ids.mpy_id ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment