I'm trying to match the codes/descriptions from table_2
to each company in table_1
. The company_type_string
column contains multiple codes separated by ~
that are supposed to match with the codes in table_2
.
Table 1:
company company_type_string
------------------------------
A 1A~2B~3C
B 1A~2B
C 1A
D 1A~2B~3C~4D
Table 2:
code description
-----------------------
1A Finance
2B Law
3C Security
4D Marketing
Desired output:
company description
----------------------
A Finance
A Law
A Security
B Finance
B Law
C Finance
D Finance
D Law
D Security
D Marketing
I've tried using split_string with no success. Is there a way to make this join without altering the DB schema?