Php 不从mysql json数据类型返回数据
我通过where条件从mysql的json字段中搜索数据。但没有数据显示 “attributes_list”的MySql字段名,json类型 我的json数据:Php 不从mysql json数据类型返回数据,php,mysql,json,jsonschema,Php,Mysql,Json,Jsonschema,我通过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" },
{
"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';
但是当我运行这个程序时,没有显示数据
SELECT * FROM products where attributes_list->'$[0]."0".text' = 'Canada';
SELECT * FROM products where attributes_list->'$[0]."*".text' = 'Canada';
我解释我的情况:
产品表中有6行。在产品表中,有一个字段用于命名属性列表
此字段为json类型。一个产品有多个保存属性。我的属性列表json格式是
{"0":{"id":"","text":""},"1":{"id":"","text":""}}.
现在我想搜索text='Canada'的位置,然后根据mySql选择器$**读取这些产品信息
[在页面上搜索(路径$**.b)以到达那里。]
这将搜索每个文档的第二级,并在第二级返回文本键的值。
因此,您的查询如下所示:
SELECT * FROM products where attributes_list->'$.*.text' = 'Canada';
此外,我还尝试执行与您在中提到的相同的任务,我尝试了您的查询,但这不起作用。我在运行“从产品中选择json_深度(属性列表)”时提到的另一件事是显示深度级别3。您是否检查了上面的更新查询@SanaulIshaque?是的,我运行了更新查询,但没有找到结果。