如果它们看起来像这样,你可以加入2个表吗?
表1
Key_ID Item
1234.P User 123
4324.P User 234
5432.P User 345
表2
Key_ID Item
1234.J Computer ABC
4324.J Computer DEF
5432.J Computer GHI
如果我可以消除每个Key_ID的最后2个字符,则值将是相同的。这些方面有什么用吗?
FROM [Table 1]
INNER JOIN [Table 2]
ON Left(([Table 1].Key_ID), Len([Table 1].Key_ID) - 2) =
Left(([Table 2].Key_ID), Len([Table 2].Key_ID) - 2)
Key_ID中句点左侧的值可能包含字母字符,可能多于或少于4个字符。
答案 0 :(得分:2)
我刚在Access 2007中试过这个:
- 假设所有KEY_ID值都是####。A
的惰性方式SELECT *
FROM Table1 AS T
INNER JOIN Table2 AS T2 ON LEFT(T.Key_ID,4) = LEFT(T2.Key_ID,4);
- 如果您想加入期间左侧的所有内容
SELECT *
FROM Table1 AS T
INNER JOIN Table2 AS T2 ON Mid(T.Key_ID,1,Instr(1,T.Key_ID,".",1)-1) = Mid(T2.Key_ID,1,Instr(1,T2.Key_ID,".",1)-1);