【问题标题】:I want select all duplicate records from my table on the basis of student name and father name in mysql database我想根据 mysql 数据库中的学生姓名和父亲姓名从我的表中选择所有重复记录
【发布时间】:2022-01-22 14:51:24
【问题描述】:
select student_name 
from thewings_clients_temp 
where concat(student_name,father_name) IN (
    select concat(student_name,father_name) from thewings_clients_temp group by student_name HAVING COUNT(concat(student_name,father_name)) > 1
)

【问题讨论】:

  • 希望你的表有主键? SELECT DISTINCT t1.* FROM table t1 JOIN table t2 USING (student_name,father_name) WHERE t1.id <> t2.id;
  • 重复记录在同一张表中是这样的......
  • 您对此有何疑问?如果您需要帮助,请分享表结构、示例输入数据、相应的预期输出,以及有关当前查询不工作的更多详细信息

标签: mysql sql


【解决方案1】:

这将为您提供名字重复多次的学生。

SELECT student_name,
       father_name,
       COUNT(*)
FROM thewings_clients_temp 
GROUP BY student_name, father_name
HAVING COUNT(*) > 1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 1970-01-01
    相关资源
    最近更新 更多