The JSON path array accessor accepts a list of elements to pick:
SELECT JSON_QUERY('["A", "B", "C"]', '$[0,2]'
WITH ARRAY WRAPPER
)
FROM …
The JSON path expression [0,2]
in this example returns the JSON elements "A"
and "C"
.
Primer: “JSON Path”
Other SQL/JSON path array accessors:
The SQL/JSON path language first appeared in ISO/IEC 9075:2016-2 as part of optional feature T833, “SQL/JSON path language: multiple subscripts”.
The essence of SQL tuning in 200 pages
Buy on Amazon
(paperback only)
Paperback and PDF also available at Markus’ store.
Markus offers SQL training and consulting for developers working at companies of any size.
Learn more »