SQL 중복 제거 쿼리 방법: 단일 필드 peopleId를 기준으로 중복 레코드를 판단하고 명령문을 사용하여 삭제합니다. 코드는 [여기서 peopleId는 (peopleId별로 people 그룹에서 peopleId 선택)]입니다.
SQL 중복 제거 쿼리 방법:
중복 레코드를 제거하기 위한
sql 단일 테이블/다중 테이블 쿼리단일 테이블 구별여러 테이블 그룹 기준그룹 기준은 주문 기준 및 제한 이전에 배치되어야 하며, 그렇지 않으면 오류가 보고됩니다1. 테이블에서 초과된 부분 찾기 중복 레코드, 단일 필드(peopleId)를 기준으로 중복 레코드 판단select * from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
delete from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1) and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)
select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
delete from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
Select Name,Count(*) From A Group By Name Having Count(*) > 1
Select Name,sex,Count(*) From A Group By Name,sex Having Count(*) > 1
declare @max integer,@id integer declare cur_rows cursor local for select 主字段,count(*) from 表名 group by 主字段 having count(*) >; 1 open cur_rows fetch cur_rows into @id,@max while @@fetch_status=0 begin select @max = @max -1 set rowcount @max delete from 表名 where 主字段 = @id fetch cur_rows into @id,@max end close cur_rows set rowcount 0
select distinct * from tableName
select distinct * into #Tmp from tableName drop table tableName select * into tableName from #Tmp drop table #Tmp
select identity(int,1,1) as autoID, * into #Tmp from tableName select min(autoID) as autoID into #Tmp2 from #Tmp group by Name,autoID select * from #Tmp where autoID in(select autoID from #tmp2)
select * from tablename where id in (select id from tablename group by id having count(id) > 1 )
select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)로그인 후 복사3. 테이블에서 중복된 레코드를 찾습니다(다중 필드). rrreee는 where(a.peopleId,a. seq)은 통과하지 못할 것입니다! ! !
🎜관련 학습 권장 사항: 🎜SQL 비디오 튜토리얼🎜🎜🎜위 내용은 SQL에서 중복 쿼리를 제거하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!