当前位置:网站首页>Tips for extracting JSON fields from MySQL
Tips for extracting JSON fields from MySQL
2022-07-05 17:14:00 【1024 questions】
mysql Take out json Field skills
mysql Using functions in JSON_EXTRACT()
spark sql Use in get_json_object()
mysql take json, In don't know key Under the circumstances , Take his value Detailed value
mysql Take out json Field skillsSometimes some information will be written in json Forms exist in the database , If it's too long , In the process of taking sql It will run slower , If you only take some key values, it will be more wasteful
mysql Using functions in JSON_EXTRACT()±—±---------------------------------------------------------------+| id | data |±—±---------------------------------------------------------------+| 1 | {“Tel”: “132223232444”, “name”: “david”, “address”: “Beijing”} || 2 | {“Tel”: “13390989765”, “name”: “Mike”, “address”: “Guangzhou”} |±—±---------------------------------------------------------------+
select json_extract('{"name":"Zhaim","tel":"13240133388"}',"$.tel");
spark sql Use in get_json_object()select get_json_object(i.extra, '$.sale_currency');select sum(get_json_object(i.extra, '$.sale_price') * i.count) as sale_price;
mysql take json, In don't know key Under the circumstances , Take his value Detailed value { "selects" :{ "20071090" :{ "NN" : 41,"LXFS1" : "12365","GH" : "20071090","RZZW" : " Director of General Office ","sxzym" : " Garden plants and ornamental gardening ","ZC" : " associate professor ","XGW" : " Administration and logistics ","XB" : " male ","ZZMM" : " Party members ","ZWZC" : " Senior title ","MZ" : " han ","CSRQ" : 307123200000,"XL" : " master ","selectKey" : "20071090","XM" : " Zhang San ","GZBM" : " The office ","PZGW" : " Associate professor level III post ","XW" : " Master of Agriculture " }}}
In this mysql If you want to get a name in red under the database, the content is as shown in the above figure
Create view , Take the name of this field , Because of his key:"20071090" Is dynamic uncertainty , And it will only appear once in this place , First I take the first floor key==>selects The next value
SELECT ZDLSXM->'$.selects' from VI_YXGR
On this basis , Take down another layer , Because this layer is dynamic key, Cannot use the first step ZDLSXM->'$.selects' That way , So I choose substring_index Method Remove the braces , Reuse CONCAT() Splicing becomes new json, Delete the red part of the following icon
SELECT CONCAT("{",substring_index(substring_index(ZDLSXM->'$.selects', '{', -1),"}",1),"}") from VI_YXGR
Another layer of packaging can take the name
SELECT SE_ZDLSXM->'$.name' AS ZDLSXM from (SELECT CONCAT("{",substring_index(substring_index(ZDLSXM->'$.selects', '{', -1),"}",1),"}") as SE_ZDLSXM from VI_YXGR) sss
The above is personal experience , I hope I can give you a reference , I also hope you can support the software development network .
边栏推荐
- URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加
- 浏览器渲染原理以及重排与重绘
- WR | 西湖大学鞠峰组揭示微塑料污染对人工湿地菌群与脱氮功能的影响
- 网站页面禁止复制内容 JS代码
- Is it safe to open futures accounts online? Will there be more liars online? Doesn't feel very reliable?
- 【剑指 Offer】62. 圆圈中最后剩下的数字
- [Jianzhi offer] 62 The last remaining number in the circle
- SQL删除重复数据的实例教程
- 麻烦问下,DMS中使用Redis语法是以云数据库Redis社区版的命令为参考的嘛
- 启牛商学院股票开户安全吗?靠谱吗?
猜你喜欢
一个满分的项目文档是如何书写的|得物技术
深耕5G,芯讯通持续推动5G应用百花齐放
How to write a full score project document | acquisition technology
High number | summary of calculation methods of volume of rotating body, double integral calculation of volume of rotating body
dried food! Semi supervised pre training dialogue model space
composer安装报错:No composer.lock file present.
激动人心!2022开放原子全球开源峰会报名火热开启!
First day of learning C language
基于51单片机的电子时钟设计
The first EMQ in China joined Amazon cloud technology's "startup acceleration - global partner network program"
随机推荐
CMake教程Step2(添加库)
张平安:加快云上数字创新,共建产业智慧生态
Is it safe for qiniu business school to open a stock account? Is it reliable?
Embedded UC (UNIX System Advanced Programming) -2
网上办理期货开户安全吗?网上会不会骗子比较多?感觉不太靠谱?
国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」
通过proc接口调试内核代码
编译libssh2报错找不到openssl
composer安装报错:No composer.lock file present.
Use JDBC technology and MySQL database management system to realize the function of course management, including adding, modifying, querying and deleting course information.
【剑指 Offer】63. 股票的最大利润
CMake教程Step3(添加库的使用要求)
手机开证券账户安全吗?怎么买股票详细步骤
Embedded UC (UNIX System Advanced Programming) -3
[Jianzhi offer] 63 Maximum profit of stock
一文了解MySQL事务隔离级别
dried food! Semi supervised pre training dialogue model space
[729. My schedule I]
Jarvis OJ Flag
CMake教程Step4(安装和测试)