Skip to content

Instantly share code, notes, and snippets.

@ryancole
Created January 9, 2013 17:58
Show Gist options
  • Save ryancole/4495272 to your computer and use it in GitHub Desktop.
Save ryancole/4495272 to your computer and use it in GitHub Desktop.
Query for records with more than X number of foreign key matches.
SELECT t.emplid
FROM term_file t
WHERE t.emplid IN (SELECT v.custodian_id FROM evidence_main v GROUP BY v.custodian_id HAVING COUNT(v.custodian_id) > 50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment