刪除Person表中重複的Email,只留下id最小的Email
Person表,主鍵是Id
+----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email protected] | +----+------------------+結果:
+----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected] | +----+------------------+SQL語句:
delete a from Person as a,Person as b where a.id>b.id and a.Email=b.Email;