如何使用select查询在stringifed JSON中查找值

时间:2018-01-24 05:44:07

标签: json sqlite

我想检查一个特定的id是否在一个列中可用,该列在字符串化JSON中存储数据。我可以使用select语句吗。我使用了update语句和replace函数来改变json中的值。但是如何在json中查找id是否存在。

[{"name":"Ramesh","mobile_no":"6420000000","location":"Erode","type":"Worker","contact_id":2237,"farmer_id":84,"date":"2018-01-19T05:55:31.283Z","category":"Working","transaction_type":"WorkerWork","amount_in":80,"user_type":"Worker","id":11532}]

1 个答案:

答案 0 :(得分:0)

请尝试以下代码:

SELECT * FROM table_name WHERE instr(column_name, '"contact_id":2237') > 0;

如果您只想要总计数

SELECT count(*) as alias_name FROM table_name WHERE instr(Column_name, '"contact_id":2237') > 0;

请记住instr是区分大小写的