CrystalVis
Technical User
I need to join two tables by account_id field. Where the account_id in the second table (let call it table B) is populated with the account_id from the first table (let call it table A), a colon and one digit. For example:
acount_id in table A is 1234567, there are some processing done in the backend and then account_id in table B is populated as follow: 1234567:1.
I need to join these two table on account_id. This is what I have so far
SELECT
A.Name,
A.PhoneNumber,
B.Duration
B.Add_Dtm
From A
Join B
ON A.account_id = SUBSTRING(B.account_id,1,7)
This query will give me the desire result as long as the account_id is 7 characters long. However, the account_id will varies (some accounts are 8 characters long others are 9 characters long), which will mess up the join statement. What I try to accomplish is match the account_id in table A with the account_id in table B up to the position before the colon. I hope my description make sense. If not, please ask. Your help is greatly appreciated.
TIA
by the way, the data type of the account_id field is varchar.
acount_id in table A is 1234567, there are some processing done in the backend and then account_id in table B is populated as follow: 1234567:1.
I need to join these two table on account_id. This is what I have so far
SELECT
A.Name,
A.PhoneNumber,
B.Duration
B.Add_Dtm
From A
Join B
ON A.account_id = SUBSTRING(B.account_id,1,7)
This query will give me the desire result as long as the account_id is 7 characters long. However, the account_id will varies (some accounts are 8 characters long others are 9 characters long), which will mess up the join statement. What I try to accomplish is match the account_id in table A with the account_id in table B up to the position before the colon. I hope my description make sense. If not, please ask. Your help is greatly appreciated.
TIA
by the way, the data type of the account_id field is varchar.