I'm using DB Manager on QGIS to write a view. I want to "translate" unnest()
SQL function, but I don't find the same in SQLite.
SQL
SELECT unnest(ARRAY['A','B','C']);
unnest |
---|
A |
B |
C |
The documentation describes two aggregate functions and two table-valued functions. I tried json_each
, which returns a row for each json
value but I can't display unnested values.
SQLite
SELECT myfield
FROM my_table, json_each(my_field);
my_field |
---|
["A", "B", "C" ] |
["A", "B", "C" ] |
["A", "B", "C" ] |
How to easily unnest json
elements in SQLite?
SQLite
there is no such function: unnestunnest
in my linked answer, that's not a function but a virtual table name of the recursive CTE expresion that mimics an unnest. However, you may want to try thejson_tree
variant to also walk children. If that doesn't unnest the array values of your JSON, you have to use the recursive CTE as in my linked answer. And you will have to use the recursive CTE if your array is not a valid JSON in the first place...