I have two tables with multiple columns and the primary key is the same but not the same length. 1 is only 8000 rows and the other 10.7 million. I am trying to take the 8000 and compare it to the 10.7 million and get all the data from the 10.7 million based on the primary key in the 8000 row table. The key looks like this:
table1 table2
CustNbr1 CustNbr2
00800900 0800900
00810900 0810900
00811900 0811900
00912480 3912480
I have tried to do a join query and the query looks like this and it comes up with no results every time.
select right([custnbr1],6) as expr1, right([custnbr2],6) as expr2, table2.subid, table2.ind from table1 inner join table2 on table1.custnbr1=table2.custnbr2;
Now remember I typed this by looking at my work laptop and just manually typing so I can't copy and paste and if I missed some () or [] I apologize. The SQL is right in my work laptop. I just can't go to sites on my work laptop like this. They are not allowed.
I have already tried doing an update query on table 1 to make the length only 7 however if you notice the last number in the line, 1 has 00 in the beginning and the other 3. The digit prior to the 6 numbers is called our obligor ID and it can vary from 0 to 6. The last 6 digits are always the same and are always the custnbr. it is just some systems put 00 before every custnbr and some put the obligor ID before the custnbr. I have a work around by updating each table to be only the 6 digits and then query but the 10.7 million row table2 takes like 4 hours to run the update query and I was hoping for something a bit faster.