Contents

System/OS
2013.04.23 14:35

[sql] 중복데이터 삭제 쿼리

Views 14734 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
MySQL에서 될지는 모르겠지만..
(SubQuery가능한 버젼이면 된다네요..)

DELETE FROM tab WHERE 번호 NOT IN
    ( SELECT MIN(번호) FROM tab GROUP BY 이름, 나이, 전화번호, 주소필드 );

위의 쿼리를 설명하자면..
번호를 제외한 나머지 컬럼들이 동일할때 번호에 대한 Min값을 구해서
Min이 아닌 번호를 가진 레코드들을 모두 삭제해 줌으로써
동일 정보에 대한 레코드를 제거하는 로직입니다.


?

List of Articles
No. Category Subject Author Date Views
106 System/OS [linux] ipfwadm를 이용한 패킷필터링(구버전) hooni 2003.04.23 13015
105 System/OS [linux] Proftpd 설치 가이드 hooni 2003.04.23 13021
104 System/OS [linux] DHCP(Dynamic Host Configuration Protocol) 서버 hooni 2003.04.23 13023
103 System/OS [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치) hooni 2013.04.23 13057
102 System/OS [linux] 계정관리하기(내공쌓기) hooni 2003.04.23 13157
101 System/OS [linux] 아파치설치/설정 - SSI(Server Side Include) hooni 2003.04.23 13206
100 System/OS [linux] Xwindow/Xmanager 사용 hooni 2003.04.23 13332
99 System/OS [ms-sql] 프로시져 예제.. file hooni 2013.04.23 13406
98 System/OS [linux] 쉘 스크립트에 대한 설명과 예제.. hooni 2003.04.23 13413
97 System/OS [linux] 프로그램 설치방법 (내공쌓기) hooni 2003.04.23 13433
96 System/OS [linux] 간단한 vi편집기 사용 명령 hooni 2003.04.23 13456
95 System/OS [linux] 기존 환경설정 저장하면서 커널 컴파일.. hooni 2003.04.23 13456
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 ... 17 Next
/ 17