我有以下value
作为 JSON 类型的架构
mysql> select * from people;
+------+---------------------------------------------------------------------------+
| id | value |
+------+---------------------------------------------------------------------------+
| blah | {"key1": "value1", "key2": "value2"} |
| foo | {"key1": "value1", "friends": [{"friendId": "123"}, {"friendId": "foo"}]} |
+------+---------------------------------------------------------------------------+
我希望下面的查询返回我的行foo
,但它没有。
mysql> select * from people where value->'$.friends[*].friendId' = "123";
Empty set
该条件value->'$.friends[*].friendId'
似乎有效,因为它适用于以下查询:
mysql> select value->'$.friends[*].friendId' from people;
+---------------------------------+
| value->'$.friends[*].friendId' |
+---------------------------------+
| NULL |
| ["123", "foo"] |
+---------------------------------+
那么查询是怎么来的select * from people where value->'$.friends[*].friendId' = "123";
没有返回结果呢?