当前位置:   article > 正文

Mysql基础学习:mysql8 JSON字段查询操作_mysql8 json查询

mysql8 json查询

一、查询JSON中某个属性值为XXX的数据量

1、方式一

        select count(*)
        from table_name
        where JSON_CONTAINS(json-> '$.filed1', '"xxx"')
           or JSON_CONTAINS(json-> '$.filed2', '"xxx"')
  • 1
  • 2
  • 3
  • 4

2、方式二

select name from data_asset_measure where JSON_EXTRACT(json, '$.filed1') = "name";
  • 1

二、查询的JSON中的value并去除双引号

 select CAST(TRIM(BOTH '"' FROM JSON_EXTRACT(json, '$.xx')) as DECIMAL) as xxx,
        from table_name;
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/988920
推荐阅读
相关标签
  

闽ICP备14008679号