Suppose I have 2 tables obtained from a web form submission, with some checkboxes results stored as "string" format as describerd here in "hobby" column https://dbfiddle.uk/?rdbms=mysql_5.7&fiddle=aff4e50085be40930e223b00a1ac81f3,
How could I join this two tables and obtain the following result?
sub_id | datimkt |
---|---|
1 | Basket,Gas,SUV |
2 | Basket,Cabrio,Football,hybrid |
I've tried to execute the following query, but it only takes the first result from the checkbox result field.
SELECT GROUP_CONCAT(DISTINCT submission_id)sub_id,
GROUP_CONCAT(DISTINCT c1.option_name)datimkt
FROM form_results d
JOIN field_options c1 ON FIND_IN_SET(c1.option_value, d.datimkt)
GROUP BY d.datimkt;
SELECT*FROM result2;