[英]Query mysql json column array using AND NOT CONTAINS (mysql 5.7)
[英]Query a JSON column to extract the selected map in Array List of Mysql 5.7
我正在使用 Mysql 5.7,它有以下數據集。
mysql> select id, browser from events;
+----+--------------------------------------------------------------------+
| id | browser |
+----+--------------------------------------------------------------------+
| 1 | [{"price": "10.00", "tag": "60"}, {"price": "25.00", "tag": "20"}] |
| 2 | [{"price": "8.00", "tag": "10"}, {"price": "25.00", "tag": "20 "}] |
+----+--------------------------------------------------------------------+
我只想從這個數據集中提取以下地圖。 (不是整個數組列表)
{"price": "10.00", "tag": "60"}
我嘗試了以下命令,但提供了一個空集。
mysql> select * from events where json_contains(browser->'$[*].price', json_object('price',"10.00"));
Empty set (0.00 sec)
有人可以解釋一下為什么它不起作用或如何查詢包含price =10.00的地圖嗎?
SELECT browser,JSON_EXTRACT(browser,"$.price")
FROM events t
WHERE JSON_EXTRACT(browser,"$.price")=10.00
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.