Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从 mysql 数据库的一个表中生成重复数据。当我单击生成或查找按钮时,它将选择所有重复的数据。它还将基于相同的名称和生日。但有时我们与其他人同名但生日不同。
例如:样本数据库:
预期输出:
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)
内部查询返回COUNT与外部查询相同Name, MiddleName, LastName, BirthData的记录,我们只需要这些记录,我们有超过 1 条记录。
COUNT
Name, MiddleName, LastName, BirthData