2022-11-29:查找重复的电子邮箱。以下数据中a@b.com是重复的,请写出sql语句。

DROP TABLE IF EXISTS person;
CREATE TABLE person (
  id int(11) NOT NULL,
  email varchar(255) NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO person VALUES ('1', 'a@b.com');
INSERT INTO person VALUES ('2', 'c@d.com');
INSERT INTO person VALUES ('3', 'a@b.com');

答案2022-11-29:

sql语句如下:

select email
from person
group by email
having count(email) > 1;

执行结果如下: 在这里插入图片描述