当前位置:网站首页>How MySQL uses JSON_ Extract() takes JSON value
How MySQL uses JSON_ Extract() takes JSON value
2022-07-05 17:14:00 【1024 questions】
mysql take json The value of a key under the string field
1. Use replace() Replace
2. Use JSON_UNQUOTE()
mysql Handle json character string ,JSON_EXTRACT() Extract content
MySQL since 5.7 After that, I started to support json type
mysql take json The value of a key under the string fieldrequirement :mysql edition 5.7 And above
SELECT JSON_EXTRACT('{"uid":"asas02234"}', "$.uid");because json The key value of is in double quotation marks . So you need to remove the double quotation marks .
1. Use replace() Replaceselect replace(JSON_EXTRACT(infoJson,'$.uid'),'"','') uidfrom userslaravel Use in JSON_EXTRACT
$applyList = DB::table('invoice') ->select('applied_at','total_amount','invoice_form','invoice_file','reject_reason') ->selectRAW('replace(JSON_EXTRACT(invoice_detail,"$.owner_name"),\'"\',\'\') as owner_name') ->where('uid',Auth::id())->get();2. Use JSON_UNQUOTE()SELECT JSON_UNQUOTE(JSON_EXTRACT('{"id":"3"}', "$.id"));$applyList = DB::table('invoice') ->select('applied_at','total_amount','invoice_form','invoice_file','reject_reason') ->selectRAW('JSON_UNQUOTE(JSON_EXTRACT(invoice_detail,"$.owner_name")) as owner_name') ->where('uid',Auth::id())->get();mysql Handle json character string ,JSON_EXTRACT() Extract content MySQL since 5.7 After that, I started to support json type The corresponding analytic function is mainly JSON_EXTRACT():
SELECT JSON_EXTRACT('{"ID":"1"}','$.ID');Execution results :
JSON_EXTRACT('{"ID":"1"}','$.ID')
"1"
Remove quotation marks and use functions JSON_UNQUOTE():
SELECT JSON_UNQUOTE(JSON_EXTRACT('{"ID":"1"}','$.ID'));Execution results :
JSON_UNQUOTE(JSON_EXTRACT('{"ID":"1"}','$.ID'))
1
The above is personal experience , I hope I can give you a reference , I also hope you can support the software development network .
边栏推荐
- Embedded -arm (bare board development) -1
- CMake教程Step3(添加库的使用要求)
- Machine learning compilation lesson 2: tensor program abstraction
- Embedded UC (UNIX System Advanced Programming) -3
- 云安全日报220705:红帽PHP解释器发现执行任意代码漏洞,需要尽快升级
- 通过proc接口调试内核代码
- C language to get program running time
- 外盘期货平台如何辨别正规安全?
- [729. My schedule I]
- Excuse me, is the redis syntax used in DMS based on the commands of the redis community version of the cloud database
猜你喜欢

Embedded -arm (bare board development) -1

腾讯音乐上线新产品“曲易买”,提供音乐商用版权授权

Etcd build a highly available etcd cluster
![[first lecture on robot coordinate system]](/img/3c/af056f0fe68b3244a3dc491ceb291d.png)
[first lecture on robot coordinate system]

thinkphp模板的使用
一文了解MySQL事务隔离级别

Iphone14 with pill screen may trigger a rush for Chinese consumers

PHP talent recruitment system development source code recruitment website source code secondary development

机器学习02:模型评估
MYSQL group by 有哪些注意事项
随机推荐
Error in compiling libssh2. OpenSSL cannot be found
2022 年 Q2 加密市场投融资报告:GameFi 成为投资关键词
Embedded-c Language-1
Application of threshold homomorphic encryption in privacy Computing: Interpretation
Use byte stream to read Chinese from file to console display
SQL删除重复数据的实例教程
Embedded UC (UNIX System Advanced Programming) -3
[729. My schedule I]
机器学习01:绪论
ECU简介
Read the basic grammar of C language in one article
【微信小程序】一文读懂小程序的生命周期和路由跳转
关于mysql中的json解析函数JSON_EXTRACT
Is it safe for qiniu business school to open a stock account? Is it reliable?
Practical example of propeller easydl: automatic scratch recognition of industrial parts
机器学习编译第2讲:张量程序抽象
麻烦问下,DMS中使用Redis语法是以云数据库Redis社区版的命令为参考的嘛
深耕5G,芯讯通持续推动5G应用百花齐放
通过proc接口调试内核代码
WSL2.0安装