Suppose I have json data type column named data, and this column contains array of hashes, so for example: [{x:1, y:2}, {x:3, y:4},...]
假设我有名为data的json数据类型列,并且此列包含哈希数组,例如:[{x:1,y:2},{x:3,y:4},...]
Now can I json search this array for specific value of some key? That is select rows which have a hash with value of x
key equal to 5, is this possible ?
现在我可以在json中搜索此数组以获取某些键的具体值吗?这是具有值为x key等于5的散列的选择行,这可能吗?
1 个解决方案
#1
0
Well I think I found a solution for it
好吧,我想我找到了解决方案
SELECT * FROM table where JSON_CONTAINS(JSON_EXTRACT(data, '$[*].x'), 'search_val' = 1"
SELECT * FROM表,其中JSON_CONTAINS(JSON_EXTRACT(数据,'$ [*]。x'),'search_val'= 1“
#1
0
Well I think I found a solution for it
好吧,我想我找到了解决方案
SELECT * FROM table where JSON_CONTAINS(JSON_EXTRACT(data, '$[*].x'), 'search_val' = 1"
SELECT * FROM表,其中JSON_CONTAINS(JSON_EXTRACT(数据,'$ [*]。x'),'search_val'= 1“