简体   繁体   English

如何在 MySQL 中搜索 JSON 数组字段?

[英]How to search JSON array field in MySQL?

I have a column which has json type arrays like我有一列具有 json 类型的数组,例如

row1: ["abc", 10, null, true, false]
row2: ["def", 10, null, true, false]

How can i use where clause to find "abc" contained rows?如何使用where子句查找"abc"包含的行? My json arrays has no key.我的 json 数组没有键。 They only have values.他们只有价值观。

select * from myTable where JSON_SEARCH(myColumn,"all","abc")

returns 0 rows返回 0 行

您可以使用MySQL JSON 搜索功能JSON_CONTAINS()

where json_contains(myColumn, '"abc"')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM