来自另一个表的类似sql的

drnojrws  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(219)

我有两张table:
表1中customername列为字符串:

1,2,3,101,102,customerA,customerB.

表2中的changeidstring:00001,0000200101,客户。
现在我想连接这两个表,因为我知道changeid 00001是customer 1,changeid 00101是customer 101,changeid customera是off-course customera,但是由于零,我尝试使用like,但是失败了。
你们知道怎么把这两张table连起来吗?

ghg1uchk

ghg1uchk1#

您可以使用旧的“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

如果速度太慢,请将其中一个表写入临时表,其中final id和changeid将具有匹配的数据类型。

相关问题