SQLite 資料庫的 TEXT 列包含如下 json 值:
[{"key1":"116"},{"key2":"260"},{"key3":"123"},{"key4":"1155"},{"key4":"1507"}]
我需要一個不同的json 鍵串列
key1 1
key2 1
key3 1
key4 2
我可以只使用 sqlite json 函式撰寫視圖嗎?
uj5u.com熱心網友回復:
您需要JSON1 擴展功能,例如json_each()和聚合:
SELECT j.key, COUNT(*) counter
FROM (
SELECT j.*
FROM tablename t, json_each(col) j
-- WHERE ... (if you want to apply a filter in the table's rows)
) t, json_each(t.value) j
GROUP BY j.key;
查看演示
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/415037.html
標籤:
