I have one column in MySQL which is return me comma separated value , I want to convert that column in to rows.
Better answer then How to convert comma separated parameters to rows in mysql?
select value from table limit 1
response
| value |
|---|
| honda,activa,pleasure,car |
I want this value to row like
| value |
|---|
| honda |
| activa |
| pleasure |
| car |
>Solution :
CREATE TABLE response (id INT, value TEXT)
SELECT 1 id, 'honda,activa,pleasure,car' value;
SELECT response.id, jsontable.value
FROM response
CROSS JOIN JSON_TABLE(CONCAT('["', REPLACE(value, ',', '","'), '"]'),
'$[*]' COLUMNS (value TEXT PATH '$')) jsontable;
| id | value |
|---|---|
| 1 | honda |
| 1 | activa |
| 1 | pleasure |
| 1 | car |
PS. The query assumes that the value does not contain duoble quotes. If they are present then they must be quoted. See https://dbfiddle.uk/HUmPZEo1