在JOIN查询中使用LIKE [英] Using LIKE in a JOIN query
本文介绍了在JOIN查询中使用LIKE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个单独的数据表.
I have two separate data tables.
这是Table1
:
Customer Name Address 1 City State Zip
ACME COMPANY 1 Street Road Maspeth NY 11777
这是Table2
:
Customer Active Account New Contact
ACME Y John Smith
我正在使用JOIN
运行查询,其中仅包括来自两个表的联接字段相等的行.
I am running a query using the JOIN
where only include rows where the joined fields from both tables are equal.
我正在加入Table1
中的Customer Name
和Table2
中的Customer
.显然没有匹配.我想做的是显示每个表中前4个字符匹配的结果,以便得到结果或匹配项.可以使用LIKE
或LEFT
吗?
I am joining Customer Name
from Table1
and Customer
from Table2
. Obviously no match. What I am trying to do is show results where the first 4 characters match in each table so I get a result or match. Is this possible using LIKE
or LEFT
?
推荐答案
似乎应该可行:
Select *
From Table1, Table2
Where Table1.CustomerName Like Cat('%',Trim(Table2.CustomerName),'%')
这篇关于在JOIN查询中使用LIKE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文