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 8413467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:55:39+00:00 2026-06-10T00:55:39+00:00

I have a MySQL database containing names and addresses, but there are some duplicate

  • 0

I have a MySQL database containing names and addresses, but there are some duplicate names with only partial addresses such as

Name  | Address 
========================
Smith | 10 Main St., Cincinnati, OH 45202
Smith | 10 Main St.

I need a SQL query to select all rows with a duplicate name and the shorter of the two LIKE addresses. I was able to use GROUP BY and COUNT() for exact duplicates, but I don’t know of a way to apply that to substrings like the example above. Any ideas? Thanks.

  • 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-06-10T00:55:40+00:00Added an answer on June 10, 2026 at 12:55 am

    Something like this should work:

    select * from mytable as t1
     inner join mytable as t2
     on t1.Name = t2.Name
     and t1.Address like concat(t2.Address, '%')
     and t1.Address != t2.Address;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql database with table 'product' containing columns 'product_id', 'name', 'price' table
I have a MYSQL database containing the names of a large collection of people.
I am getting the image names from mysql database. I have my images containing
Have a PHP/MySQL form with a dropdown box containing a list of 350 names.
I have a MySQL database with words containing accents in Spanish (áéíóú). I'd like
I have a pre-existing mysql database containing around 50 tables. Rather than hand code
I have two MySQL database tables: one containing a list of championships and another
--EDITED TO BETTER DESCRIBE THE SCENARIO-- I have a MySQL database containing 2 tables,
I have a MySQL database containing a user's country and whether they are an
I have a MySQL database containing a person's forename, surname, their country, and whether

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.