[leetcode] 196. Delete Duplicate Emails
DELETE 1. 기본 구문 DELETE FROM 테이블명 ; 2. 조건이 있을때 DELETE FROM 테이블명 WHERE 조건절 ; 리트코드 정답 쿼리 1. 서브쿼리 사용 DELETE FROM person WHERE id NOT IN (SELECT sub.min_id FROM (SELECT email, MIN(id) AS min_id FROM person GROUP BY email )sub ) 2. 셀프 조인 사용 DELETE p1 FROM person AS p1 INNER JOIN person AS p2 ON p1.email = p2.email WHERE p1.id > p2.id
2022.10.25