MySql

mysql json 查询

2023-01-08  本文已影响0人  Rinaloving

mysql json 查询

1. 普通 json 查询

{
    "id":"142"
}
select  * from table where data->'$.id' = 142;
  1. 数组格式查询

[
    {
        "Code":"320000",
        "SDataArr":[
            {
                "CityCode":"320100",
                "SDataArr":[
                    {
                        "AreaCode":"320102",
                        "SDataArr":[

                        ]
                    },
                    {
                        "AreaCode":"320104",
                        "SDataArr":[

                        ]
                    },
                    {
                        "AreaCode":"320106",
                        "SDataArr":[

                        ]
                    }
                ]
            },
            {
                "CityCode":"320800",
                "SDataArr":[
                    {
                        "AreaCode":"320829",
                        "SDataArr":[

                        ]
                    },
                    {
                        "AreaCode":"320830",
                        "SDataArr":[

                        ]
                    }
                ]
            }
        ]
    }
]

SELECT  JSON_EXTRACT(sRegionalRelations,'$[0].Code') FROM `TbCityStudy` 
json查询.png

参考文档

上一篇下一篇

猜你喜欢

热点阅读