Home > Software engineering >  left -join-on-concat-fields
left -join-on-concat-fields

Time:11-08

I have to join (required to use join) these 2 tables table and table B.

I have table A

CoverID
4!12569
3!18175
1!478931

And Table B

ID Accountid
4 12569
3 18175
1 478931

Please advise how can I join the table using concat

CodePudding user response:

From TableA A
Left join TableB B
On A.CoverId = (concat(B.ID, ‘!’, B.AccountId)) 

You need to make sure the data types match. So you’ll have to play around with whether or not you need to cast the data to match within the concatenation besides that it should work.

  • Related