我有一张下表
Id Avatar
1 Smarty.resident
2 ticklethis.resident
3 Renae resident
4 ticklethis
5 Smarty resident
6 Hirpantemp
7 loveyoubaby
8 Hirpantemp.resident
9 Renae
10 Sweetme
11 ticklethis resident
我无法编写SQL命令来获取类似名称,如下面的
Id Avatar
1 Smarty.resident
5 Smarty resident
2 ticklethis.resident
4 ticklethis
11 ticklethis resident
3 Renae resident
9 Renae
6 Hirpantemp
8 Hirpantemp.resident
答案 0 :(得分:1)
对于替换中的假设,这有点可疑,但这可能适用于给定的数据集:
select ID, Avatar
from MyTable
where replace(replace(Avatar, '.resident', ''), ' resident', '') in (
select replace(replace(Avatar, '.resident', ''), ' resident', '') as Avatar
from MyTable
group by replace(replace(Avatar, '.resident', ''), ' resident', '')
having count(*) > 1
)