比如数据: [{“name”: “attribute_type”,“value”: 8},{“name”: “attribute_type”,“value”: 222}] 需求:判断所有此字段中是否存在value值为222的数据
create table t_json(id int IDENTITY(1,1), c2 varchar2(1000) CHECK (c2 is json)); insert into SYSDBA."t_json"(c2) values('{"name": "attribute_type","value": 8}'); insert into SYSDBA."t_json"(c2) values('{"name": "attribute_type","value": 222}'); commit; SELECT ID,json_value(c2, '$.value') json_value FROM t_json; select 1 from t_json where json_value(c2, '$.value') =222;
更多JSON相关内容可参考:https://eco.dameng.com/document/dm/zh-cn/pm/json#18.2%20%E5%87%BD%E6%95%B0
create table t_json(id int IDENTITY(1,1), c2 varchar2(1000) CHECK (c2 is json)); insert into SYSDBA."t_json"(c2) values('{"name": "attribute_type","value": 8}'); insert into SYSDBA."t_json"(c2) values('{"name": "attribute_type","value": 222}'); commit; SELECT ID,json_value(c2, '$.value') json_value FROM t_json; select 1 from t_json where json_value(c2, '$.value') =222;
更多JSON相关内容可参考:https://eco.dameng.com/document/dm/zh-cn/pm/json#18.2%20%E5%87%BD%E6%95%B0