[英]Fuzzy match column to column
I'm trying to find a way to match a column of clean data in table 1 to a column of dirty data in table2 without making any changes to the dirty data. 我试图找到一种方法,将表1中的干净数据列与表2中的脏数据列匹配,而不对脏数据进行任何更改。 I was thinking a fuzzy match, but there are too many entries in the clean table to allow for CDEs to be used. 我当时在考虑模糊匹配,但是干净表中的条目太多,无法使用CDE。 So, for example: 因此,例如:
Table 1
GroupID CompanyName
123 CompanyA
445 CompanyB
556 CompanyC
Table 2
GroupID Patientname
AE123789 PatientA
123987 PatientB
445111 PatientC
And I'm trying to match the insurance company to the patient using the group number. 我正在尝试使用组号将保险公司与患者匹配。 Is there a matching method out there? 有匹配的方法吗? (Fortunately the group numbers are actually much longer and when looking for a single group's worth of patients, fuzzy matching works really well, so they seem to be unique enough to be applied here). (幸运的是,组数实际上更长,并且在寻找单个组的患者价值时,模糊匹配的确非常有效,因此它们似乎足够独特,可以在此处应用)。
Working in SQL server 2008. 在SQL Server 2008中工作。
This changes slightly depending on which database you are using, but it looks like you're looking for something like this: 根据您所使用的数据库,这会略有变化,但是看起来您正在寻找如下内容:
MSSQL MSSQL
select *
from table1 t1
join table2 t2 on t2.groupid like '%'+cast(t1.groupid as varchar(max))+'%'
MySQL - use Concat()
: Concat()
使用Concat()
:
select *
from table1 t1
join table2 t2 on t2.groupid like concat('%',t1.groupid,'%')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.