Contents

Views 3402 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에서는 Sub Query 가능한 버전이어야 함.


mysql> delete from tab where 번호 not in
    -> ( select min(번호) from tab group by 이름, 나이, 전화번호, 주소필드 );


위의 쿼리를 설명하자면..

번호를 제외한 나머지 컬럼들이 동일할때 번호에 대한 Min값을 구해서 Min이 아닌 번호를 가진 레코드들을 모두 삭제해 줌으로써 동일 정보에 대한 레코드를 제거하는 로직임.



?