加入两个没有共同列的表

时间:2022-10-26 07:51:48

I am working with two tables with no columns that I can easily join to and get the data I want.

我正在使用两个没有列的表,我可以轻松地加入并获取我想要的数据。

Information about the tables:

有关表格的信息:

I do see something in common in both tables that I might be able to use to join, but I am not sure how it can be done.

我确实在两个表中看到了一些我可以用来加入的共同点,但我不确定它是如何完成的。

Table1: has a column called File_Name. This column captures the imported file location.
example: C:\123\3455\344534\3fjkfj.txt. max Lenth = 200.

Table1:有一个名为File_Name的列。此列捕获导入的文件位置。例如:C:\ 123 \ 3455 \ 344534 \ 3fjkfj.txt。最大Lenth = 200。

Table2: has a column called batch_ID and contains all the records imported by the file listed in table1.
The batch_ID column is exact same thing has the File_Name column in table1.
However, the difference is that it only allows the lenth = 50. Pretty much it only shows last 50 characters of a filename and directory (50 characters from right to left.)
max lenth = 50

表2:有一个名为batch_ID的列,包含table1中列出的文件导入的所有记录。 batch_ID列与table1中的File_Name列完全相同。但是,不同之处在于它只允许lenth = 50.几乎只显示文件名和目录的最后50个字符(从右到左50个字符。)max lenth = 50

Example: ..\344534\3fjkfj.txt (basically cuts off characters if more than 50 in lenth).

示例:.. \ 344534 \ 3fjkfj.txt(如果长度超过50,则基本上会切断字符)。

How would I join these tables on those two columns? I know I can create a function and temp tables, but how can I do it without it?

我如何在这两列上加入这些表?我知道我可以创建一个函数和临时表,但是如果没有它我怎么能这样做呢?

Thanks!

1 个解决方案

#1


3  

Select Columns
From   Table1 
       Inner Join Table2
          On Right(Table1.ColumnA, 50) = Right(Table2.ColumnB, 50)

#1


3  

Select Columns
From   Table1 
       Inner Join Table2
          On Right(Table1.ColumnA, 50) = Right(Table2.ColumnB, 50)