I'm trying to find duplicate ( matched names ) records in a table.
-----------------------------------
|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 |
-----------------------------------
i want to filter records which are repeated with same name like Birmingham United Kingdom , Blackburn United Kingdom , Bilbao Area Italy
result expected
-----------------------------------
|id | name |
-----------------------------------
| 2 | Biella Area, Italy |
-----------------------------------
| 3 | Bilbao Area, Italy |
-----------------------------------
| 4 | Birmingham, United Kingdom |
-----------------------------------
| 5 | Blackburn, United Kingdom |
-----------------------------------
| 6 | Blackpool, United Kingdom |
-----------------------------------
I have tried below query but not working.
select p.*
from countries p
left join countries u
on concat('|', p.name, '|') like concat('%|', u.name, '|%')