I'm trying to store some data from a temporary query into a table, but it doesn't work.
Suppose we have the following data
Table_A
Submission_id | Salesman | Customer name | Hobby | Carline | Fuel | Marketing_data |
---|---|---|---|---|---|---|
1 | salesman1 | customer1 | hobby1 | car1,car2 | Fuel1 | hobby1,car1,car2,Fuel1 |
2 | salesman2 | customer2 | hobby1,hobby2 | car1 | Fuel2 | hobby1,hobby2,car1,Fuel2 |
And the radio Button/checkbox value table: Table_B
option_value | option_name |
---|---|
hobby1 | Football |
hobby2 | Golf |
car1 | SUV |
car2 | Cabrio |
Fuel1 | Gas |
Fuel2 | Hybrid |
I've written the following code trying to match the options stored in the previous table against the column "Marketing_data" to obtain a new column:
SELECT GROUP_CONCAT(DISTINCT c0.option_name)Marketing_data
FROM Table_A d
JOIN Table_B c0 ON FIND_IN_SET(c0.option_value, d.Marketing_data)
GROUP BY d.Marketing_data;
And the resulting column is composed as follow:
Marketing_data |
---|
Football, SUV, Cabrio, Gas |
Football, Golf, SUV, Hybrid |
Now, what I'm trying to do is to insert the last column into the first table (Table_A). I tried with INSERT INTO command and I've also tried to generate another table containing the Submission_id field, but nothing worked. Have you got any suggestions? Many Thanks to everyone who will try to help me.