mysql - SQL - 查找列中具有相似值的行

标签 mysql sql

 ID   NAME       Email
 1    John       john@example.com
 2    Mathew     mathew@example.com
 3    John       jon@example.com
 4    Johnson    johns@example.com
 5    Peter      pete@example.com

如何创建将返回的查询

1    John       john@example.com
3    John       jon@example.com
4    Johnson    johns@example.com

类似 Find rows that have the same value on a column in MySQL 的答案返回具有相同值的行。这里我需要类似的值

最佳答案

首先获取所有具有相似电子邮件的记录,然后仅打印那些符合内部条件的记录。

 select * from table_name where email in   (
  select email from table_name 
  group by email 
  having count(*)>1 
)

经过测试,工作正常。

关于mysql - SQL - 查找列中具有相似值的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39344228/

相关文章:

sql - MySQL:用空值求平均值

python - 将 Django 与现有的复杂数据库结合使用

SQL查询源代码

sql - PHP/MySQL问题,更多的是后者

php - 从 MySQL 中删除用户不起作用

mysql - SQL - 更新表和排序依据?

mysql - mysql 5.6 是否有 ANY_VALUE 功能?

php - 使用 count() 输出每月和月份的总条目数

sql - 在 SQL Server 中将多行与列转换为单行

mysql - SQL根据多列删除同一个表中的重复行