【发布时间】:2017-01-04 06:58:09
【问题描述】:
我通过where条件从mysql的json字段中搜索数据。但没有数据显示。
“attributes_list”的MySql字段名,json类型
我的 json 数据:
{
"0":
{
"id": "01c93aae-8603-42f3-b097-89357467872a#####ed20eb29-611a-4e5c-a966-c09708c98179",
"text": "Canada",
"attr_name": "Country"
},
"1":
{
"id": "01c93aae-8603-42f3-b097-89357467872a#####6e6269a1-afbb-4d5d-b2ee-6d25fe38fec7",
"text": "Ontario",
"attr_name": "REGION"
},
"2":
{
"id": "5a0a085e-f3e4-4fbe-9f3e-61cec4836d36#####d81923c9-9532-4375-ba3d-19214ac61c4e",
"text": "Lager",
"attr_name": "TYPE"
},
"-1": {"id": "", "text": "", "attr_name": ""}
}
我对mysql的json查询:
当我运行以下查询然后显示数据
SELECT * FROM products where attributes_list->'$[0]."0".text' = 'Canada';
但是当我运行它时没有显示数据
SELECT * FROM products where attributes_list->'$[0]."*".text' = 'Canada';
我解释一下我的情况:
在产品表中有 6 行。在产品表中,有一个字段名称属性列表。
该字段为json类型。一个产品有保存多个属性。我的 attribute_list json 格式是
{"0":{"id":"","text":""},"1":{"id":"","text":""}}.
现在我想搜索 text='Canada' 的位置,然后阅读那些产品信息
【问题讨论】:
标签: php mysql json jsonschema