Collections:
JSON_REMOVE() - Removing JSON Child Members
How to remove child members of a JSON (JavaScript Object Notation) value using the JSON_REMOVE() function?
✍: FYIcenter.com
JSON_REMOVE(json, path1, path2, ...) is a MySQL built-in function that
removes child members of a JSON value at given locations,
which are specified by path arguments in the "$.key" or "$[i]" format.
For example:
SET @j = '["a", {"b": [1, 2]}, [3, 4]]';
SELECT JSON_REMOVE(@j, '$[1]'), JSON_REMOVE(@j, '$[1].b');
-- +-------------------------+---------------------------+
-- | JSON_REMOVE(@j, '$[1]') | JSON_REMOVE(@j, '$[1].b') |
-- +-------------------------+---------------------------+
-- | ["a", [3, 4]] | ["a", {}, [3, 4]] |
-- +-------------------------+---------------------------+
SELECT JSON_REMOVE(@j, '$');
ERROR 3153 (42000): The path expression '$' is not allowed in this context.
Reference information of the JSON_REMOVE() function:
JSON_REMOVE(json, path1, path2, ...): modjson Removes child members of a JSON value at given locations, which are specified by path arguments in the "$.key" or "$[i]" format. Arguments, return value and availability: json: Required. The JSON value to be updated. path1, path2, ...: One or more JSON path locations of members to be removed. modjson: Return value. The updated JSON value. Available since MySQL 5.7.
Related MySQL functions:
⇒ JSON_REPLACE() - Replacing JSON Child Members
⇐ JSON_QUOTE() - Quoting JSON String
2023-12-10, 1131🔥, 0💬
Popular Posts:
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
How to continue to the next iteration of a WHILE loop in SQL Server Transact-SQL? How to use CONTINU...
How To Format DATETIME Values to Strings with the CONVERT() Function in SQL Server Transact-SQL? SQL...
How To Format DATETIME Values to Strings with the CONVERT() Function in SQL Server Transact-SQL? SQL...
What Happens If the UPDATE Subquery Returns Multiple Rows in SQL Server? If a subquery is used in a ...