0

I need to generate duplicate data from one table of mysql database. When I click the generate or find button, it will select all the data that is duplicated. And it will also based on same names and bithday. But there are times that we have same names with other people yet different birthdays.

For example: SAMPLE DATABASE:

enter image description here

EXPECTED OUTPUT:

enter image description here

Mureinik
  • 297,002
  • 52
  • 306
  • 350

1 Answers1

0
SELECT * FROM my_table t
WHERE 1 < (SELECT COUNT(*) FROM my_table
           WHERE Name = t.Name
             AND MiddleName = t.MiddleName
             AND LastName = t.LastName
             AND BirthData = t.BirthData)

Inner query returns COUNT of recors that have the same Name, MiddleName, LastName, BirthData as in outer query and we want just these records for which we have more than 1 record.

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69