Skip to content

Instantly share code, notes, and snippets.

@hampelm
Created June 30, 2011 20:38
Show Gist options
  • Save hampelm/1057176 to your computer and use it in GitHub Desktop.
Save hampelm/1057176 to your computer and use it in GitHub Desktop.
CiviCRM Stale Contacts Query
SELECT *
FROM civicrm_contact
WHERE id NOT
IN ( 1 )
SELECT *
FROM civicrm_log
WHERE entity_table='civicrm_contact'
LEFT_JOIN civicrm_contact ON civicrm_log.entity_id=civicrm_contact.id
SELECT civicrm_log.entity_id, civicrm_contact.first_name FROM civicrm_log
LEFT JOIN civicrm_contact ON civicrm_log.entity_id=civicrm_contact.id
WHERE civicrm_log.entity_table='civicrm_contact'
SELECT first_name, last_name from civicrm_contact
WHERE id NOT IN
(
SELECT entity_id
FROM civicrm_log
WHERE entity_table='civicrm_contact'
AND modified_date > '2011-02-16 17:16:41'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment