Using MySQL 5.7, how can I select array elements from a JSON column, as rows?
Table Person
id data
1 [{"name":"one"},{"name":"two"}]
2 [{"name":"three"},{"name":"four"}]
I want to "pivot" the elements in the JSON array to rows. Non-working SQL below...
SELECT
p.id AS personId,
d->'$.name' AS name
FROM
Person p
JSON_EXTRACT(p.data) d # <-- not valid SQL
WHERE
d->'$.name' <> 'three'
Expected Output
personId name
1 one
1 two
2 four