参数2中的JSON文本无效-MySQL 5.7.8中的json_contains [英] Invalid JSON text in argument 2 - json_contains in MySQL 5.7.8

查看:2237
本文介绍了参数2中的JSON文本无效-MySQL 5.7.8中的json_contains的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,该数据库的一列是字符串的JSON(例如["ART","LIT"]等).我想使用json_contains进行搜索.

I have a database with one column that is JSON of strings (ex. ["ART","LIT"], etc.). I want to search it using json_contains.

但是,当我尝试:

json_contains(\`column_name`,"ART")

错误提示:

函数json_contains的参数2中的无效JSON文本:无效值".在"ART"中的位置0.

Invalid JSON text in argument 2 to function json_contains: "Invalid value." at position 0 in 'ART'.

请注意,json_contains不会错误地使用数字代替"ART",而只是使用字符串.知道我该如何解决/解决这个问题吗?

Note that json_contains doesn't error with numbers in the place of "ART", just with strings. Any idea what I can do to fix/get around this?

推荐答案

显然,它将整数与字符串区别对待.虽然json_contains(`column_name`,"1")是有效的调用,但要检查它是否包含"ART",则必须使用json_contains(`column_name`,'"ART"').

Apparently, it treats integers differently from strings. While json_contains(`column_name`,"1") is a valid call, to check if it contains "ART", you must use json_contains(`column_name`,'"ART"').

那解决了我的问题!

这篇关于参数2中的JSON文本无效-MySQL 5.7.8中的json_contains的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆