mysql触发器json_MYSQL触发器:JSON_SEARCH整数的json数组中的整数值

bd96500e110b49cbb3cd949968f18be7.png

I am looking to use json_search to get the array path that corresponds to a value.

I have tried and this works:

SET @j = '["3", "2", "1"]';

SELECT json_search(@j, 'one', '2');

returns $[1];

I have tried and this doesn't work: (How do I make this work?)

SET @j = '[3, 2, 1]';

SELECT json_search(@j, 'one', 2);

returns null;

Basically I want to store @j as an integer array instead of a string array for indexing purposes. Is there any way I can change the integer array into a string array for comparison if there is no way for json_search to work with integers?

解决方案

It is by design, although I can not agree with mySQL team. This should be implemented.

The specification at https://dev.mysql.com/worklog/task/?id=7909 says:

"This function returns path(s) to the given string. The returned

path(s) identify object members or array slots which are character

strings."

So it seems that the intention of this function was to search for

strings. The documentation should be updated to clarify that the

function is for searching for string scalars, not for scalars in

general.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值