我正在尝试在表中查找重复的(匹配名称)记录。
-----------------------------------
|id | name |
-----------------------------------
| 1 | Bielefeld Area, Germany |
-----------------------------------
| 2 | Biella Area, Italy |
-----------------------------------
| 3 | Bilbao Area, Italy |
-----------------------------------
| 4 | Birmingham, United Kingdom |
-----------------------------------
| 5 | Blackburn, United Kingdom |
-----------------------------------
| 6 | Blackpool, United Kingdom |
-----------------------------------
| 7 | Bogotá D.C. Area, Colombia |
-----------------------------------
我想过滤重复记录,例如伯明翰英国,布莱克本英国,意大利毕尔巴鄂地区
预期结果
-----------------------------------
|id | name |
-----------------------------------
| 2 | Biella Area, Italy |
-----------------------------------
| 3 | Bilbao Area, Italy |
-----------------------------------
| 4 | Birmingham, United Kingdom |
-----------------------------------
| 5 | Blackburn, United Kingdom |
-----------------------------------
| 6 | Blackpool, United Kingdom |
-----------------------------------
我已经尝试过下面的查询,但是没有用。
select p.*
from countries p
left join countries u
on concat('|', p.name, '|') like concat('%|', u.name, '|%')
答案 0 :(得分:0)
您可以在此处使用group by
Select count(id) as count, name from countries group by countries.name