Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 614195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:05:10+00:00 2026-05-13T18:05:10+00:00

I would like to find all duplicate records by name in a customer table

  • 0

I would like to find all duplicate records by name in a customer table using MySQL including those that do not match exactly.

I know I can use the query

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 with a LIKE clause. For instance there might be a customer with the name “Mark’s Widgets” and another “Mark’s Widgets Inc.” I would like my query to find these as duplicates. So something along the lines of

SELECT id, name AS name1 ... WHERE name1 LIKE CONCAT("%", name2, "%") ...

I know that’s completely incorrect but that’s the idea. Here is the able schema:

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:05:11+00:00Added an answer on May 13, 2026 at 6:05 pm

    It’s quite possible to do this, but before you even begin you need to define your rules regarding what is a match and what is not, without that you can’t go anywhere.

    You could, for example, ignore the first and last 3 characters of the name and match on the middle characters, or you could choose more complex logic, but there is no magic method of achieving what you want, you will have to code the logic. Whatever your choice it needs to be defined before you start and before we can really help much.

    No mysql here so excuse the syntax errors ( its t-sql syntax if any) but i’m thinking a self join

    SELECT
        t1.ID
    FROM MyTable t1
    LEFT OUTER JOIN MyTable t2
    ON t1.name LIKE CONCAT('%', t2.name, '%')
    group by t1.ID
    HAVING count(*) > 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to find out a duplicate value in the all nested arrays
I would like to find all comment blocks(/*...*/) but the function g_regex_match_full always returns
I would like to perform a regular expression in jQuery to find all the
I would like to build an excel VBA program to find all the match
Given the following: What I would like to happen: 1. Find all Span TAGS
I would like to find an API like Apache Commons that will easily and
Possible Duplicate: Clearing all cookies with javascript I would like to have a checkbox
I'm attempting to build a query that will return all non duplicate (unique) records
I have a table with a varchar column, and I would like to find
I would like to find a way using Linq to filter a navigation property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.