本文介绍了如何在 sqlite 中使用json 查询, 目标是从保存的json array中,找到匹配的id。
这个使用场景,是为文章,增加标签,然后查询 所有包含某个标签的文章
先来看看数据表结构
-- auto-generated definitioncreate table json_test_table( id int, content json);create unique index json_test_table_id_uindex on json_test_table (id);
我们定义了这样一个表,content是存放的json字段
我们先插入一点数据
INSERT INTO json_test_table (id, content) VALUES (2, '[7, 6, 13]')