Find possible duplicates in two columns ignoring case and special characters

后端 未结 3 1044
北海茫月
北海茫月 2021-02-09 05:22

Query

SELECT COUNT(*), name, number
FROM   tbl
GROUP  BY name, number
HAVING COUNT(*) > 1

It sometimes fails to find duplicates between lowe

3条回答
  •  不思量自难忘°
    2021-02-09 06:11

    PostgreSQL by default is case sensitive. You can force it to be case-insensitive during searches by converting all values to a single case:

    SELECT COUNT(*), lower(name), number FROM TABLE 
    GROUP BY lower(name), number HAVING COUNT(*) > 1
    
    • NOTE: This has not been tested in Postgres

提交回复
热议问题