【问题标题】:Finding Duplicate Entry from multiple table in mysql从mysql中的多个表中查找重复条目
【发布时间】:2016-01-13 20:15:07
【问题描述】:

我有三个具有以下结构的表

表名:用户

id        name      age
1         Alok       26
2         Ashok      28
3         Amit       25

表名称:部门

id        name      d_name
1         Alok       Ops
2         Amit       IT
3         Shekahr    CS

我想要使用 mysql 查询的总计数重复的名称

   total     name
   2         Alok
   2         Amit
   1         Ashok
   1         Shekhar

请帮忙

提前致谢。

【问题讨论】:

    标签: mysql duplicate-data


    【解决方案1】:

    试试这个:

    select count(*) as total,name  from (
    select name from users
    union 
    all select * from deepartment ) as temp
    group by name
    

    Union all 将合并您的表,并与group bycount 一起获得预期的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-26
      • 1970-01-01
      • 2018-08-29
      • 1970-01-01
      相关资源
      最近更新 更多