Extract values from JSON columns or strings with JSON_EXTRACT and related helpers.
JSON_EXTRACT() reads a JSON document and returns the value found at the supplied path. It works on JSON, LONGTEXT, or VARCHAR columns that contain valid JSON and supports multiple path arguments in one call.
Use JSON_EXTRACT(column, '$.path') or the shorthand column->'$.path'. Wrap the call with JSON_UNQUOTE() when you want plain text instead of a JSON value.
SELECT JSON_UNQUOTE(address->'$.city') AS city FROM Customers WHERE id = 1; returns “Berlin” when the address column stores {"city":"Berlin","zip":"10115"}.
Call JSON_EXTRACT('{"name":"Laptop","spec":{"ram":16}}', '$.spec.ram'); This returns 16 without any table reference, useful for quick tests.
Combine JSON_EXTRACT in WHERE. Example: SELECT * FROM Products WHERE JSON_EXTRACT(attributes,'$.color') = '"red"'; Add a generated column color GENERATED ALWAYS AS (JSON_UNQUOTE(attributes->'$.color')) STORED and index it for speed.
Validate input with JSON_VALID(), use generated columns to index frequent paths, avoid wildcard paths that disable indexes, and keep JSON documents small to prevent full-row scans.
Yes, because the function must parse the JSON at runtime. Use generated columns and indexes when you query the same path often.
Yes. Use JSON_SET(column,'$.key', new_value). The function returns an updated JSON document that you can write back with UPDATE.
No. Unlike MySQL, MariaDB stores JSON as plain LONGTEXT, so size and validation depend on your application layer.