I have a column of long constructed strings. Somewhere in these strings (not always in the same location) there should be at least 1 portion that matches some item in a list I want to join on. The string portion im looking for has underscores on either side. i.e.
Id LongString
1 asd_Name1_af_2
2 asd_asd_Name2_3
3 wou_do_Name3_5_123
The list of potential matches would look like
PotentialNames
Name1
Name2
The end result I am looking for is
Id LongString PotentialNames
1 asd_Name1_af_2 Name1
2 asd_asd_Name2_3 Name2
3 wou_do_Name3_5_123 Null
I have tried two things
doing a partial string lookup (i.e. JOIN PotentialNames b ON a.LongString LIKE concat('%\',b.PotentialNames ,'\%' ) But I want to also include the case where there is no match or LongString is blank
splitting the LongString (SPLIT(LongString , '_')), but I then can't join with the given "array"