Contents

System/OS
2013.04.23 14:35

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

Views 14735 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
405 Etc [link] 유용한 사이트 링크. hooni 2013.08.19 71465
404 System/OS [linux] /etc/fstab 설정 방법.. ㅋㅋ hooni 2013.04.23 12083
403 System/OS [linux] apache, php, jsp 환경설정하기.. hooni 2003.04.23 15244
402 System/OS [linux] APM(apache, php, mysql) + gd 설치순서.. hooni 2003.04.23 18852
401 System/OS [linux] awk 명령어 hooni 2014.03.11 4957
400 System/OS [linux] CentOS 6.5 에서 "Bringing up interface eth0: Determining if ip address 121.78.127.197 is already in use for device eth0..." hooni 2014.04.05 4851
399 System/OS [linux] CentOS 6.x Cati 설치 (yum) hooni 2014.01.17 48596
398 System/OS [linux] CentOS Apache Httpd에 https 적용 hooni 2014.03.05 4483
397 Develop [linux] CentOS Apache 웹서버에 HTTPS 적용 hooni 2015.10.23 790
396 System/OS [linux] CentOS 에 APM 설치하기 hooni 2015.01.02 1696
395 System/OS [linux] CentOS 터미널 언어 설정(한글/영어) hooni 2013.12.22 18517
394 Develop [linux] crond 사용법.. ㅋㅋ hooni 2013.04.23 7246
Board Pagination Prev 1 ... 60 61 62 63 64 65 66 67 68 69 ... 98 Next
/ 98