匹配名称

时间:2010-06-29 17:07:06

标签: ms-access-2007

我有两张桌子。 CustomersTable和BusinessDirectory
两个表都有一个名为businessName的列 我的CustomerTable有一个列cid,customerID,businessName 我的BusinessDirectory表有bdid,businessName,getID

我想通过CustomerTable中的customerID更新BusinessDirectory表中的getID字段,其中企业名称在CustomerTable中匹配。因此我做了这个查询

update BusinessDirectory INNER JOIN CustomerTable ON CustomerTable.businessName = BusinessDirectory.businessName set BusinessDirectory.getID = CustomerTable.customerID;

只要记录匹配100%,就会更新记录。有些记录中有一些小错字和东西 就像我在一张桌子上有一个商业名称General Contractors Inc,另一张桌子将它作为总承包商。正如你可以看到它缺少的Inc,所以它不匹配。我该怎么做才能获得最佳匹配。 谢谢

1 个答案:

答案 0 :(得分:1)

这应该有效,但不是特别安全:

UPDATE BusinessDirectory, CustomerTable 
SET BusinessDirectory.getID = CustomerTable.customerID
WHERE BusinessDirectory.businessName Like
Left(CustomerTable.businessName,InstrRev(CustomerTable.businessName," ")) & "*"