I would like to find all duplicate entries by name in the client table using MySQL, including those that do not match exactly.
I know I can use the request
SELECT id, name FROM customer GROUP BY name HAVING count(*) > 1;
to find all rows that match exactly, but I want to find all duplicate rows matching the LIKE . For example, there may be a client named "Mark Widgets" and another "Mark Widgets Inc.", I would like my query to find them as duplicates. So, something like
SELECT id, name AS name1 ... WHERE name1 LIKE CONCAT("%", name2, "%") ...
I know what is completely wrong, but what an idea. Here is a capable diagram:
mysql> describe customer; +-----------------------------+--------------+------+-----+------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------------------+--------------+------+-----+------------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(140) | NO | | NULL | | ...
EDIT: To clarify, I want to find all duplicates, not just duplicates of one specific customer name.
markb source share