There is totally a way of doing this faster in tsql, string_split can convert a column containing CSV data into a joinable table which makes dealing with very silly old data much easier. Have heard people using JSON data types to do this also but not sure how off top of head. Hopefully there may be an equivalent in mysql?