日期:2025-07-14 04:13:56 人气:1

    A+
热门评论

sql如何查询两个表不重复的记录

sql 查询不重复的记录 可以使用 having count group by 组合 先把不重复数据的id查询出来 通过count()计算 只有数目为1的才是不重复的数据 然后通过in选择出不重复记录的数据 例子: 统计出a表中name不重复的所有记录 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重复的数据的列名

阅读全文

sql查询语句怎么排除重复数据

select id, name, memo from A where id in (select id from A group by id having count(1) >= 2) select id, name, memo from A where id in (select id from A group by id having count(1) >= 2)

阅读全文