I have a table name tech_id contains field CORP,Contractor. There is another table name LastValidTech contains four fields, Account1, Account2, Account3, Account4. Table structure is first 4 digits of LastValidTech (Account1,Account2,Account3,Account4) is CORP.
tech_id
CORP,CONTRACTOR
1211,ABC
1222,EFG
1333,KKL
LastValidTech
TicketNo, Account1, Account2, Account3, Account4
1122,01211-12345-01
1123, ,01222-32456-93
1124, 01333-73737-04
Some times the Account1 has a value, Some times Account2 in another record has a value and same some times Account3 and Account4 has a value. How to i join both tables in a sense that if Account1 has a value and match with first 4 digits of CORP then it will connect to CORP or if Account2 has a value and match with first 4 digit with CORP it will connect to CORP or if Account3 and Account4 has a value and match with first 4 digit with CORP then it will connect to CORP.
Thanks.