简体   繁体   English

MySQL:如何使用 JSON 数据搜索字段?

[英]MySQL: How to search a field with JSON Data?

My question is specifically for MySQL 5.6 which does not have JSON search support.我的问题是专门针对不支持 JSON 搜索的 MySQL 5.6。

I have thousands of records and I have to check the json field state from a JSON structure.我有数千条记录,我必须从 JSON 结构中检查 json 字段state I have to check that return all records where JSON field state does not contain - , hyphen.我必须检查是否返回 JSON 字段state不包含- 、连字符的所有记录。 LIKE seems costly. LIKE似乎很昂贵。 Is there anyother way to do it?有没有其他方法可以做到?

If you're stuck on 5.6, then it looks like you're stuck using like rlike or regexp , sorry...如果你停留在5.6,那么它看起来像你坚持使用like rlikeregexp ,对不起......

And if you're stuck on 5.6 and asking what will be fastest: I'd go the regexp route.如果你坚持使用 5.6 并询问什么是最快的:我会走正则regexp路线。

Source: comments and other answers from this post - How to search JSON data in mysql?来源:来自这篇文章的评论和其他答案 - 如何在 mysql 中搜索 JSON 数据?

Dumb question, can you update to mysql 5.7?愚蠢的问题,你能更新到mysql 5.7吗? Your life will be a lot easier if you do.如果你这样做,你的生活会轻松很多。

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

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