Skip to content

Instantly share code, notes, and snippets.

@AugustoCalaca
Created September 10, 2021 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AugustoCalaca/9f200be4387f5901e53d395ff34f2896 to your computer and use it in GitHub Desktop.
Save AugustoCalaca/9f200be4387f5901e53d395ff34f2896 to your computer and use it in GitHub Desktop.
How to find duplicate text values with postgres
select id, name from table t1
where (
select count(*) from table t2
where regexp_replace(unaccent(trim(t1.name)), '\W+', '', 'g') ilike regexp_replace(unaccent(trim(t2.name)), '\W+', '', 'g')
) > 1
order by name asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment