Home > database >  Mysql grammar question
Mysql grammar question

Time:09-20

The delete from Person2
Where the Email (in the select Email from Person2 group by Email having a count (Email) & gt; 1) and
Id not in (select min (Id) from Person2 group by Email having a count (Email) & gt; 1);

This passage suggests grammar question, but I couldn't find the problem, the great god, please give directions

CodePudding user response:

The select min (Id) from Person2 group by Email having a count (Email) & gt; 1
To count (*)

CodePudding user response:

The DELETE FROM Person2
WHERE Email (the SELECT b.E IN mail FROM (SELECT Email FROM Person2 GROUP BY Email HAVING a COUNT (1) & gt; 1) AND b)
Id NOT IN (SELECT Anderson d the FROM (SELECT MIN (Id) Id FROM Person2 GROUP BY Email HAVING a COUNT (Email) & gt; 1) a);

Aggregation function cannot be used as constants, the result set need to bread a layer, the query to the result set, as fixed field can delete action;
  • Related