`cast( value as UNSIGNED)` stops processing `value...
# sql
c
cast( value as UNSIGNED)
stops processing
value
as soon as it encounters something that does not represent a number, iirc. So here it would stop at the comma. What you could try is to build the join on a LIKE clause:
ON x.opt_code LIKE concat( '%', y.opt_code_id, '%')
Definitely not the fastest join, but, it should work