美文网首页
SQL Server查询重复数据

SQL Server查询重复数据

作者: yichen_china | 来源:发表于2021-09-28 09:25 被阅读0次

    1.查询单列重复:

    select * from test where name in (select name from test group by name having count(name) > 1)
    

    2.查询多列重复

    SELECT a.* FROM test a,(
    SELECT name,code
    FROM test
    GROUP BY name,code
    HAVING COUNT(1)>1
    
    ) AS b
    WHERE a.name=b.name AND a.code=b.code
    

    相关文章

      网友评论

          本文标题:SQL Server查询重复数据

          本文链接:https://www.haomeiwen.com/subject/kiplnltx.html