我如何获得部分匹配? [英] How do I get a partial match?

查看:102
本文介绍了我如何获得部分匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究这个问题,我想知道是否有人可以帮助我。我有2个表,每个表有5个字段。 4个字段是2个字符串,然后最后一个字段是完整值。
[EX 1:

Table1 ............ ....表2

Seg1:10 ............. Seg1:10

Seg2:11 ....... ...... Seg2:11

Seg3:15 ............. Seg3:15

Seg4:01 ...... .......... Seg4:Null

决赛:10111501 ...决赛:101115]

[前2:

表1 ................表2

Seg1:10 .............第1节:10

Seg2:11 ............. Seg2:11

Seg3:15 ............. Seg3:15

Seg4:01 ............. Seg4:01

决赛:10111501 ...决赛:10111501]



我知道如何匹配他们相同的决赛,但我需要匹配与最大数量的段数部分匹配的地方。因此,在上面我需要排除完全匹配EX 2并将10111501与101115匹配,就像在EX 1中一样,但是我无法使其工作。

任何帮助都会非常感谢。

解决方案

这听起来非常像作业,但你是否将Table1中的一条记录与Table2中的特定记录相匹配,或者全部/任何一位?您是否尝试在查询中执行此操作?


我不确定我确切地知道您在问什么,您可能需要澄清更多信息。但是,如果我猜,你可以使用IIF函数和LEN函数比较字段。


示例:

展开 | 选择 | Wrap | 行号


AJ,


感谢您提供的信息。我不确定这会对我需要的东西起作用。基本上我有2个表1可能有10111501而另一个可能有101115没有最后一个段。我试图找到一种有效和快速的方法。我能够通过Sub查询来完成它,但它们需要永远运行。


让我们知道这对你是否有意义。


-James

I have been working on this for a while now and I wanted to see if someone could assist me. I have 2 tables each with 5 fields. 4 of the fields are 2 character strings, then the final field is the full value.
[EX 1:
Table1................Table2
Seg1: 10.............Seg1: 10
Seg2: 11.............Seg2: 11
Seg3: 15.............Seg3: 15
Seg4: 01.............Seg4: Null
Final: 10111501...Final: 101115]
[Ex 2:
Table1................Table2
Seg1: 10.............Seg1: 10
Seg2: 11.............Seg2: 11
Seg3: 15.............Seg3: 15
Seg4: 01.............Seg4: 01
Final: 10111501...Final: 10111501]


I know how to match the finals where they are equal but I need to match where there is a partial match with the greatest number of Segments. So in the above I would need to exclude the exact match EX 2 and match 10111501 to 101115 like in EX 1, however I have not been able to get this to work.

Any assistance would be greatly appreciated.

解决方案

This sounds very much like an assignment, but are you matching one record from Table1 with a specific record in Table2, or all/any of them? Are you trying to do this in a query?


I''m not sure I know exactly what you are asking, you may need to clarify more. But if I were to guess, you could compare the fields, using a IIF function and a LEN function.

example:

Expand|Select|Wrap|Line Numbers


AJ,

Thanks for the information. I am not sure this will work for what I need though. Basically I have 2 tables 1 may have 10111501 and the other may have 101115 without the last segment. I am trying to figure out a way to do this that is efficient and quick. I was able to do it with Sub queries but they take forever to run.

Let e know if this makes sense to you.

-James


这篇关于我如何获得部分匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆