如何编写一个sql来比较两个字符串并将结果作为百分比匹配? [英] How to write a sql to compare two strings and get the result as a percentage match?
问题描述
HI,
我想比较一系列字符串,如下所示
rodeo rodas >
胡萝卜箱
GLX GLX 1.1
GLX glxs
比较不需要区分大小写
i我正在尝试编写一个sql,我在第二个字符串中更新第一个字符串,如果它们大致匹配。除了第二个字符串之外,所有其他示例都匹配。我想写一个更新字符串的查询,除了第二个。
这可以直接在查询中。
谢谢
I am trying to compare a series of strings like the following
rodeo rodas
carrot crate
GLX GLX 1.1
GLX glxs
the comparision need not be case sensitive
i am trying to write a sql where i am updating the first string with the second string if they match approximately. Here except the second string all the other examples match. I would like to write a query which updates the strings except the second one.
is this possible directly in a query.
thanks
推荐答案
当然,如果你将100个IIf语句串在一起,这在SQL中是可行的。我不推荐它。但是,您可以从更新查询中调用函数,在该查询中可以确定是否应更新字符串。但要意识到,确定字符串是否近似匹配。需要付出相当大的努力。
Sure, this is possible in SQL if you string together 100 IIf statements. I wouldn''t recommend it. You can, however, call a function from an update query, in which you determine whether a string should be updated. Realize though, determining whether strings "approximately match" is going to take quite a bit of effort.
Chip当然还有钱。
如果你已经停止了至少要考虑实现这种松散定义的概念所需的代码的复杂性,你会知道这是一个非常复杂的问题。
考虑到你甚至都不是能够以远程逻辑方式定义问题。这是一个如何涉及这一切的线索。
作为您问题的直接答案,假设您有一个可用的功能,将为您执行此类比较,是的,可以在查询中包含它。它需要在标准模块中定义为公共范围,但是如果它在那时它将是可用的。
Chip''s on the money again of course.
If you''ve stopped at all to consider the complexity of code that would be required to implement such a loosely defined concept, you will know this is an extremely complex issue.
Consider that you weren''t even able to define the question in a remotely logical way. That is a clue to how involved this all is.
As a direct answer to your question though, assuming you have a function available that will perform this type of comparison for you, yes you can include it in a query. It would need to be defined as Public in a standard module to be in scope, but if it were then it would be usable.
我已经设法找到一个函数。该算法基于Levenshtein距离,其中计算两个串相等所需的变化数。我试图以某种方式使用与此功能相似的功能来尝试进行比较
well i have managed to find a function. The algorithm is based on Levenshtein distance where the number of changes required for the two strings to be equal is calculated. i am trying somehow to use the like function with this function to try to get the comparison
这篇关于如何编写一个sql来比较两个字符串并将结果作为百分比匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!