当前位置:小百通网>问答百科>

sql查询表中所有记录但不重复

人气:461℃/时间:2024-05-03 08:01:03

sql 查询不重复的记录 可以使用 having count group by 组合

先把不重复数据的id查询出来 通过count()计算 只有数目为1的才是不重复的数据

select b.* from table b where b.id in(select a.id from table a group by a.name having count(a.id) <2)//其中 name重复的数据的列名

  • 字典|词典|成语|诗词|美文|谜语|问答
    ©2024 小百通网 All Rights Reserved.
    手机版/电脑版