2

How do I access the value of a object property, inside an array, using JSON_QUERY in MariaDB? I have a JSON field with following data, and want to access the value of the section property.

[
  [
    {"section": "search"}
  ]
]

The following SQL is returning NULL

SELECT JSON_QUERY('[[{"section": "search"}]]', '$[0][0].section') FROM mytable

1 Answer 1

4

For anyone else having the same issue, you have to use JSON_VALUE for accessing scalar values. The following query gives the expected result.

SELECT JSON_VALUE'[[{"section": "search"}]]', '$[0][0].section') FROM mytable;

JSON_QUERY vs JSON_VALUE

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.