I have this SQL code
SELECT * FROM JSON_TABLE (('
[
"tipodenunciaid": [1,2],
"municipioid": [1,2]
]
'), '$[*]' COLUMNS (tipodenunciaid integer PATH '$.tipodenunciaid[*]', municipioid integer PATH '$.municipioid[*]'));
And I want to get the next result:
What's wrong with my query?
Thank you so much.
You can't use
json_table()
like that. If you want both arrays unnested in different columns, and lined up according to the position of each element in each array, then one option would be to separately expand each array to rows, usingordinality
to keep track of the position of each element, then join the two resultsets. Afull join
comes handy to accommodate for an unequal number of elements in each array:Demo on DB Fiddle.