[英]JSON extract from uknknown array key
I have a structure - column visitors 我有一个结构-列访问者
[{"firstname":"john","lastname":"penn"},{"firstname":"mickey","lastname":"smith"},{"firstname":"darth","lastname":"vader"}]
I would like to find out if there is a john among all these people listed inside this json. 我想找出这个json中列出的所有这些人中是否有约翰。
My quers does not find anything (no rows found) 我的酷儿找不到任何东西(找不到行)
SELECT conference_name FROM conference WHERE JSON_EXTRACT(visitors, "$[*].firstname") = 'john';
Is this possible to achieve using just json_extract and NOT json_search since it is very slow with big tables? 因为使用大表非常慢,仅使用json_extract而不使用json_search能否实现?
Like mentioned in the docs : 像文档中提到的那样:
mysql> SELECT c, JSON_EXTRACT(c, "$.firstname"), g
> FROM jemp
> WHERE JSON_EXTRACT(c, "$.firstname") = 'john';
or in your case you can try 或者您可以尝试
SELECT conference_name FROM conference WHERE JSON_EXTRACT(visitors, "$.firstname") = 'john';
or ? 要么 ?
SELECT conference.conference_name FROM conference WHERE JSON_EXTRACT(conference.visitors, "$.firstname") = 'john';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.