SyntaxStudy
Sign Up
MySQL JSON Array Operations
MySQL Intermediate 4 min read

JSON Array Operations

JSON Arrays

MySQL provides functions to work with JSON arrays: JSON_ARRAY(), JSON_ARRAYAGG(), JSON_ARRAY_APPEND(), and JSON_CONTAINS().

Example
-- 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"');
Pro Tip

JSON_CONTAINS uses strict type matching — "1" does not match 1.