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

MYSQL Triggers: JSON_SEARCH an integer value in a json array of integers(MYSQL 触发器:JSON_SEARCH json 整数数组中的整数值)
本文介绍了MYSQL 触发器:JSON_SEARCH json 整数数组中的整数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用 json_search 来获取与值对应的数组路径.

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

我试过了,这很有效:

SET @j = '["3", "2", "1"]';
SELECT json_search(@j, 'one', '2');

返回 $[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);

返回空值;

基本上我想将@j 存储为一个整数数组而不是一个用于索引目的的字符串数组.如果 json_search 无法使用整数,有什么方法可以将整数数组更改为字符串数组进行比较?

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?

推荐答案

这是设计使然,虽然我不能同意 mySQL 团队的意见.这应该被实施.

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

https://bugs.mysql.com/bug.php?id=79233 [关闭]

https://dev.mysql.com/worklog/task/中的规范?id=7909 说:"此函数返回给定字符串的路径.返回的路径标识作为字符的对象成员或数组槽字符串."

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.

这篇关于MYSQL 触发器:JSON_SEARCH json 整数数组中的整数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)