I am trying to join tables where the only 2 keys which match are table1.Account
and table2.key
But the problem is the setup. The table1.A
SQL has a substring function:
https://msdn.microsoft.com/en-us/library/ms187748.aspx
SELECT DISTINCT column1, column2
from table1
INNER JOIN table2
ON table1.Account = substring(table2.key, 3, 4)
OR table1.Account = substring(table2.key, 4, 4)
order by column1
I don't know if you need the 'or' in your on clause, but based on your question it seems like there may be two ways for those fields to match up. Regardless, you can modify the on clause, as needed, but this sample should help you with the syntax, which appears to be your obstacle.