MySQL 5.7 具有本机 JSON 支持 - 如何 select 数组中存在特定值的行?

MySQL 5.7 with native JSON support - how to select rows where a specific value exists in array?

我有一个人 Table 有一个名为 "json" 的本地 JSON 字段/列。 我的 table 的第一行在 json 列中有此内容:

{"misc": [{"sdsd": "sdsdsd"}], "size": 178, "social": {"skype": "4455454", "myspace": "fw2121ege", "twitter": "wr4541", "facebook": "frfsfsfasfsf"}, "mobility": ["forklift_sparkle", "license_for_passenger_transport", "car", "driver_license"], "piercing": true, "shoesize": 43, "trousers": {"width": 32, "length": 32}, "haircolor": "black", "shoe_size": 43, "additional_career": [{"ddgdgdg": "dggdgddg"}], "additional_social": [{"StudiVZ": "sfsfsfsf"}], "additional_language": [{"gfggfgf": "good"}], "additional_mobility": ["sfsf"]}

或此处格式正确:

http://www.jsoneditoronline.org/?id=bcceb2f1ec208ea23737ee32c1ccc5a3

所以 - 我的问题是:如何搜索值 "car" 是否存在于对象 "mobility" 中?

这不起作用:

SELECT * FROM `Persons` WHERE JSON_EXTRACT(`persons`.`json`,"$.mobility[*]") = 'car' 

(没有结果)

同样无效:

SELECT * FROM `Persons` WHERE JSON_SEARCH(`persons`.`json`, 'all', 'car', NULL, '$.mobility[*]')

(没有结果)

这个(JSON_CONTAINS)也不起作用:

SELECT * FROM `Persons` WHERE JSON_CONTAINS(`persons`.`json`, 'car', "$.mobility")

(给出错误:SELECT * FROM Persons WHERE JSON_CONTAINS(persons.json, 'car', "$.mobility ") )

但这很有效:

SELECT * FROM `Persons` WHERE JSON_CONTAINS(`persons`.`json`, '178', "$.size")

我认为这是一个问题,因为 "mobility" 包含一个数组...但是如何 select 如果该数组 "mobility" 中存在一个元素?

尝试:

SELECT *
FROM `Persons`
WHERE JSON_CONTAINS(`Persons`.`json`, '["car"]', '$.mobility');