Skip to content

Instantly share code, notes, and snippets.

@joekolade
Created April 8, 2023 14:12
Show Gist options
  • Select an option

  • Save joekolade/c5657f4bfe682c284940dea11455b85a to your computer and use it in GitHub Desktop.

Select an option

Save joekolade/c5657f4bfe682c284940dea11455b85a to your computer and use it in GitHub Desktop.
[DB Find duplicates in multiple fields]
SELECT c.uid as "CE uid", c.pid as "CE pid", uid_foreign, uid_local, count(*) as NumDuplicates
FROM sys_file_reference s
JOIN tt_content c ON (c.uid = s.uid_foreign)
WHERE s.tablenames = "tt_content"
AND s.deleted = 0
AND c.deleted = 0
GROUP BY uid_foreign, uid_local
HAVING NumDuplicates > 1
#ORDER BY c.pid ASC
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment