当前位置:网站首页>Using JSON type to realize array function in MySQL
Using JSON type to realize array function in MySQL
2022-07-27 04:27:00 【MaraSun】
mysql There are no arrays in , Sometimes it's inconvenient , You can use JSON Type data implements a class array function .
1、 Array generation
Only schematic codes are posted
...
delimiter $$
drop procedure if exists sp_JSArr;
create procedure sp_JSArr(out jsArr json )
begin
declare retJson json default "[]" ;
set retJson= json_array_append (retJson ,"$",json_object("val",1));
set retJson= json_array_append (retJson ,"$",json_object("val",2));
set jsArr = retJson;
end $$
delimiter ;
...
2、 Usage method
-- Returns an array of
call sp_JSArr(jsArr );
if JSON_VALID(jsArr ) then
-- @i Subscript variables for arrays
set @i=0;
set @ArrLen = JSON_LENGTH(jsArr );
loop_PkArr:loop -- Loop start
if @i>=@ArrLen then
leave loop_PkArr; --
end if;
-- How to use similar arrays
set @jsInex = concat("$[",i,"].val");
set @val= json_extract(jsArr ,@jsIndex) ;
set @i=@i+1;
end loop;
end if ;
MaraSun 2022-07-26 BJFWDQ
It is so hot that the temperature is 29.1 Celsius degree in the room
边栏推荐
- webpack打包vue项目添加混淆方式,解决缓存问题
- BSN IPFS(星际文件系统)专网简介、功能、架构及特性、接入说明
- Eureka service registry
- Ant JD Sina 10 architects 424 page masterpiece in-depth distributed cache from principle to practice pdf
- 使用kubesphere图形界面dashboard开启devops功能
- els 兼容性DC、传递图片到窗口
- Word/Excel 固定表格大小,填写内容时,表格不随单元格内容变化
- Manually build ABP framework from 0 -abp official complete solution and manually build simplified solution practice
- els_ 画矩形、代码规划和备份
- 无有线网络下安装并配置debian
猜你喜欢

Learning route from junior programmer to architect + complete version of supporting learning resources
![[small sample segmentation] msanet: multi similarity and attention guidance for boosting few shot segmentation](/img/b9/270e0f20586a953e83a18f7fac155f.png)
[small sample segmentation] msanet: multi similarity and attention guidance for boosting few shot segmentation

从零开始C语言精讲篇4:数组

Ribbon load balancing principle and some source codes

法解析的外部符号 “public: virtual __cdecl nvinfer1::YoloLayerPlugin::~YoloLayerPlugin(void)“ “public: virtua

Rust:axum学习笔记(1) hello world

2022 retraining question bank and answers for main principals of hazardous chemical business units

E-commerce system combined with commodity spike activities, VR panorama continues to bring benefits

Word/Excel 固定表格大小,填写内容时,表格不随单元格内容变化

电商分账系统重要吗,平台应该如何选择分账服务商呢?
随机推荐
Preliminary understanding of NiO
Navicat exports Mysql to table structure and field description
Ribbon load balancing strategy and configuration, lazy loading and hungry loading of ribbon
Webpack packaging Vue project adds confusion to solve the cache problem
Leetcode:433. minimal genetic change
Learning route from junior programmer to architect + complete version of supporting learning resources
Introduction to JVM principle
[competition reference] pytorch common code snippet and operation collection
第二轮Okaleido Tiger即将登录Binance NFT,或持续创造销售神绩
Is VR panorama just needed now? After reading it, you will understand
Cool Lehman VR panorama paves the way for you to start a business
GenericServlet为什么有两个init方法
xxx is not in the sudoers file. This incident will be reported
els 方块显示原理
JS to realize page Jump and parameter acquisition and loading
【LeetCode】Day104-无重叠区间
JVM调优中的一些常见指令
深度剖析 —— 动态内存管理
【小样本分割】MSANet: Multi-Similarity and Attention Guidance for Boosting Few-Shot Segmentation
通信协议综述