日期:2025-07-13 21:29:05 人气:1

    A+
热门评论

“sql”怎么查询不重复数据?

1、select distinct 查询字段名 。 2、查询from 表名 。 3、设置where 查询条件。 4、输入distinct是去除重复内容的。 其他解决办法: 1、先把不重复数据的id查询出来 通过count()计算 只有数目为1的才是不重复的数据。 2、然后通过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)

阅读全文