File tree Expand file tree Collapse file tree 1 file changed +0
-20
lines changed Expand file tree Collapse file tree 1 file changed +0
-20
lines changed Original file line number Diff line number Diff line change 1
- -- Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.
2
- --
3
- -- +----+------------------+
4
- -- | Id | Email |
5
- -- +----+------------------+
6
- -- | 1 | john@example.com |
7
- -- | 2 | bob@example.com |
8
- -- | 3 | john@example.com |
9
- -- +----+------------------+
10
- -- Id is the primary key column for this table.
11
- -- For example, after running your query, the above Person table should have the following rows:
12
- --
13
- -- +----+------------------+
14
- -- | Id | Email |
15
- -- +----+------------------+
16
- -- | 1 | john@example.com |
17
- -- | 2 | bob@example.com |
18
- -- +----+------------------+
19
-
20
- -- # Write your MySQL query statement below
21
1
delete p1 from Person p1, Person p2 where p1 .Email = p2 .Email and p1 .Id > p2 .Id
You can’t perform that action at this time.
0 commit comments