[英]SQL LIKE from another table
我有两张桌子:
表 1,字符串中包含 customerName 列:
1,2,3,101,102,customerA,customerB.
表 2 中的 changeID 字符串为:00001,00002,00101,customerA。
现在我想加入这两个表,因为我知道 changeID 00001 是客户 1,changeID 00101 是客户 101,而 changeID customerA 是客户 A,但是由于零我尝试使用 LIKE 但失败了。
你们有Idee如何加入这两个表吗?
您可以使用旧的“where join”:
Select Table1.*, Table2.*
From Table1, Table2
Where Table1.ID = Val(Table2.ChangeID)
或者:
Select Table1.*, Table2.*
From Table1, Table2
Where Right("0000" & Table1.ID, 5) = Table2.ChangeID
如果这太慢,请将其中一个表写入临时表,其中最终 ID 和 ChangeID 将具有匹配的数据类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.