Extract a scalar value or sub-document from a JSON column using a path expression.
Extracts values from JSON data: JSON_EXTRACT returns the raw JSON (including delimiters) while JSON_VALUE returns a scalar string. JSON_VALUE in SQL Server is the equivalent of JSON_EXTRACT in PostgreSQL. Essential for querying semi-structured data.
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | ✓ Supported | 5.7.8 | JSON_EXTRACT(col, path) returns a JSON-encoded value. The -> operator is shorthand for JSON_EXTRACT; ->> is shorthand for JSON_UNQUOTE(JSON_EXTRACT(...)) and returns unquoted text. Paths use $.key, $.key.subkey, $.array[n] notation. |
| PostgreSQL | ✓ Supported | 9.3 | The -> operator returns a JSON value; ->> returns text. For nested paths use #> (JSON) and #>> (text) with an array of keys. jsonb columns support the same operators plus GIN-indexable containment operators (@>, <@, ?, ?|, ?&). json_extract_path() and jsonb_extract_path_text() are function equivalents. |
| SQL Server | ✓ Supported | 2016 | JSON_VALUE(col, path) extracts a scalar (returns NVARCHAR). JSON_QUERY(col, path) extracts an object or array (returns NVARCHAR containing JSON). Passing the wrong function for the value type returns NULL silently. No -> operators — all access is function-based with $.key path strings. |
| Oracle | ✓ Supported | 12c | JSON_VALUE(col, path) extracts a scalar; JSON_QUERY(col, path) extracts objects or arrays. The RETURNING clause controls the output type. Error handling clauses (NULL ON ERROR, ERROR ON ERROR) prevent silent failures. Oracle 21c added JSON_TRANSFORM and dot-notation access on JSON type columns. |
| SQLite | ✓ Supported | 3.9.0 | json_extract(col, path) is the core function, available since 3.9.0. The -> and ->> operators (matching MySQL semantics) were added in SQLite 3.38.0 (2022-02-22). ->> always returns an SQL value (text/integer/real), never a JSON-encoded string. |
Path syntax is consistent across engines ($.key, $.nested.key, $.array[n]) but function names and operators diverge sharply. PostgreSQL alone uses #> / #>> for multi-key nested paths. SQL Server splits extraction into JSON_VALUE (scalars only) vs JSON_QUERY (objects/arrays only) — passing the wrong function silently returns NULL instead of an error. SQLite's -> / ->> operators arrived in 3.38.0; apps targeting older SQLite must use json_extract().
JSON_EXTRACT(col, path) returns a JSON-encoded value. The -> operator is shorthand for JSON_EXTRACT; ->> is shorthand for JSON_UNQUOTE(JSON_EXTRACT(...)) and returns unquoted text. Paths use $.key, $.key.subkey, $.array[n] notation.
The -> operator returns a JSON value; ->> returns text. For nested paths use #> (JSON) and #>> (text) with an array of keys. jsonb columns support the same operators plus GIN-indexable containment operators (@>, <@, ?, ?|, ?&). json_extract_path() and jsonb_extract_path_text() are function equivalents.
JSON_VALUE(col, path) extracts a scalar (returns NVARCHAR). JSON_QUERY(col, path) extracts an object or array (returns NVARCHAR containing JSON). Passing the wrong function for the value type returns NULL silently. No -> operators — all access is function-based with $.key path strings.
JSON_VALUE(col, path) extracts a scalar; JSON_QUERY(col, path) extracts objects or arrays. The RETURNING clause controls the output type. Error handling clauses (NULL ON ERROR, ERROR ON ERROR) prevent silent failures. Oracle 21c added JSON_TRANSFORM and dot-notation access on JSON type columns.
json_extract(col, path) is the core function, available since 3.9.0. The -> and ->> operators (matching MySQL semantics) were added in SQLite 3.38.0 (2022-02-22). ->> always returns an SQL value (text/integer/real), never a JSON-encoded string.