匹配字段由5个第一个字符组成 [英] Matching field by 5 first characters

查看:52
本文介绍了匹配字段由5个第一个字符组成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在尝试根据一个字段中的5个第一个字符将表匹配到查询中。我使用了表达式:= left([field name]),5)但是它并没有按照我的需要返回匹配的条目。基本上,我需要根据第一个字符告诉查询匹配两个字段,并显示表1中的所有记录,并且只显示表2中前5个字母匹配的记录。


这是我查询的SQL:

Hello,
I am trying to match tables into a query based on 5 first characters in one field. I used expression: =left([field name]), 5) however it does not return matched entries as I needed. Basically, I need to tell query match two fields based on first characters and and show all records from Table 1 and only those records from table 2 where first 5 letters of the fields are matching.

Here is my SQL from the query:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号

推荐答案

从我所知道的SQL看起来足够好。我尝试设置一些测试表并使用像你这样的连接而没有问题。


当你说但是它不会按照我的需要返回匹配的条目。你到底什么意思?尝试更具特色。
From what I can tell the SQL looks good enough. I tried setting up a few test tables and used a join like yours without problems.

When you say "however it does not return matched entries as I needed." what exactly do you mean? Try to be more speficic.


我现在遇到的问题是我匹配的字段可能包含我不仅需要在左边而且在中间和结尾的字符。我尝试使用= right,和= mid表达式,但有没有更好的方法将字段的任何部分与一个字段匹配?让我说我有:


走秀与猫匹配



猫步与猫匹配



Ca twalk与Cat匹配?


有道理吗?
The issue I now have is that the fields that I am matching may contain characters that I need not only at the left but in the middle and end. I tried to use =right, and =mid expressions, but is there a better way to match one field to another by any part of the field? Let say I have :

Catwalk to match to Cat
And
Cat Walk to match to Cat
And
Ca twalk to match to Cat?

Makes sense?


所以,基本上你想要当它们中的值不匹配时,SQL将记录识别为匹配,但人类可能能够识别这两个值之间的相似性。这听起来像博士论文的骨头。


对不起。我想你在这个问题上运气不好。你可以到某个地方进行特定的检查以处理具体的情况,但没有像你规定的那样一般我害怕。
So, essentially you want SQL to recognise records as matched when the values in them don''t really match, but a human might be able to recognise similarities between the two values. This sounds like the bones of a doctoral thesis.

I''m sorry. I think you''re out of luck on this one. You could get somewhere with specific checks to handle specific situations, but nothing as general as you stipulate I''m afraid.


这篇关于匹配字段由5个第一个字符组成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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