본문 바로가기

DB/MySQL

중복 데이터 찾기

select * FROM gcm_users 

WHERE smsphone 

IN (

SELECT A.smsphone AS smsphone 

            FROM ( 

           SELECT smsphone

                        FROM gcm_users 

                        GROUP BY smsphone 

                        HAVING COUNT(*)  >  1

                   )  AS A

)



smsphone 을 그룹해서 가지고 오는데 그룹된 row 가 1개 이상 일때 smsphone 가져와라 - as A

테이블.smsphone IN A.smsphone 조건인 놈들을 가져와라..


글이 더 이해하기 힘들군 ㅋㅋ ㅜㅜ;

'DB > MySQL' 카테고리의 다른 글

TRUNCATE + FOREIGN KEY  (0) 2017.05.01