Map a CSV string with ID in an association table (many to many)
DB-version: 21.11 EE
-- Problem --
I have a comma separated string. The string consists of label_ids in a random order (unsorted). I need to map that string with a association table with one row per member of the group, all sharing the same group_id.
-- Desired outcome --
I want vu_raw.id = 9249824020 to map to the highest label_group_id that matches all off the label_id:s in the csv-string. In this case the correct answer would be labels_in_group.label_group_id = 213914. There are multiple label_group_id:s that match all of the label_id:s and label_group_id = 182581 matches all it is disqualified for having one extra member. My biggest issue is with label_group_id = 313914 as it also contains one extra member, i.e. matches 6 out of 6 but it also has a seventh member AND it har a higher label_group_id than the correct answer (213914).