JSON Arrays
MySQL provides functions to work with JSON arrays: JSON_ARRAY(), JSON_ARRAYAGG(), JSON_ARRAY_APPEND(), and JSON_CONTAINS().
MySQL provides functions to work with JSON arrays: JSON_ARRAY(), JSON_ARRAYAGG(), JSON_ARRAY_APPEND(), and JSON_CONTAINS().
-- Build a JSON array
SELECT JSON_ARRAY(1, 2, 3); -- [1, 2, 3]
-- Append to array
UPDATE tags SET list = JSON_ARRAY_APPEND(list, '$', 'new-tag')
WHERE id = 1;
-- Check if array contains a value
SELECT * FROM tags WHERE JSON_CONTAINS(list, '"php"');
JSON_CONTAINS uses strict type matching — "1" does not match 1.