I need to identify records (BY THEIR FIRST SIX (6)) digits between two tables. I using the below SQL statement:
SELECT TABLE2.COMPANY_ID AS ACCOUNTS_WITH_A_STATUS, TABLE1.ACCOUNT AS MATCHING_ACCOUNTS
JOIN TABLE2 ON TABLE1.ACCOUNT = TABLE1.ACCOUNT
WHERE TABLE2.STATUS = 'A' AND TABLE2.COMPANY_ID + '%%%%%%' LIKE '%%%%%%' + TABLE1.ACCOUNT + '%%%%%%'
At first, this query seemed to work, however, it seems to be matching the LAST six digits, instead of the FIRST six digits. Please see attachment. Any assistance with this issue would be greatly appreciated.