当前位置:网站首页>Query JSON data in MySQL table
Query JSON data in MySQL table
2022-06-25 06:42:00 【Manon is by my side】
mysql Table query json data
// An highlighted block
Field attributes The value of is
{
“desc”: “{
“index”:“ Serial number ”, “startDate”:“ Start date ”, “endDate”:“ End date ”, “ruId”:“ Award rules ” }”, “name”: “ Date configuration ”, “tips”: “ Must match ”, “type”: “JSON”, “value”: “[{
“index”:1,“startDate”:“2022-02-15”,“endDate”:“2024-03-19”,“ruId”:“ru_4”}]”, “variable”: “date_config”, “configType”: “”}
1、 lookup desc, Use json_extract
select json_extract(attributes,’$.desc’) from TableName
if desc There are multiple elements under , You can use array subscripts ,desc[0]/desc[1] Take the corresponding element ; if desc The following contains multiple key value pairs , Then use desc.key Take corresponding key value
2、 Replacement available json_replace,json_set
Difference between the two
json_set() If found value exists, replace , Insert if it doesn't exist
json_replace() Replace / Modify existing values
Replace name Value
update TableName set name=json_set(attributes,’$.name’,‘ New value ’)
update TableName set name=json_replace(attributes,’$.name’,‘ New value ’)
select * from fa_trade_order WHERE json_extract(json,'$.status') ="1"
边栏推荐
- Is the number of indexes in a table the more the better?
- Understand what MTU is
- 2022 biological fermentation Exhibition (Jinan), which is a must read before the exhibition. The most comprehensive exhibition strategy will take you around the "fermentation circle"
- Ctfhub web information disclosure directory traversal
- What is VLAN
- Sleep quality today 67 points
- Cs8126t 3.1w mono ultra low EMI unfiltered class D audio power amplifier IC
- joda.time获取日期总结
- Period to string [repeat] - period to string [duplicate]
- Kubernetes cluster dashboard & kuboard installation demo
猜你喜欢

How to create a handy vs Code?

Understand what ICMP Protocol is

Cs8126t 3.1w mono ultra low EMI unfiltered class D audio power amplifier IC

Non-contact infrared temperature measurement system for human body based on single chip microcomputer

DNS domain name system

ACWING2013. 三条线

What is cloud primordial?

原子Alpha开发板--SD卡和emmc烧录工具

How to find happiness in programming and get lasting motivation?

Message queue table structure for storing message data
随机推荐
3dmax软件的制作木桶过程:三步流程
Understand what MTU is
Why can't GC () free memory- Why does gc() not free memory?
The Rust Programming Language
爱情️终结者
【ROS2】为什么要使用ROS2?《ROS2系统特性介绍》
アルマ / 炼金妹
joda.time获取日期总结
Derivation of sin (a-b) =sina*cosb-sinb*cosa
Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116
Cs5092 5V USB input boost two section lithium battery charging management IC, SOT23-6 miniature package
ACWING/2004. 错字
百度地图——入门教程
DNS domain name system
【2022黑马程序员】SQL优化
[core content and derivation] the mystery of human memory system may be just like this
SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-
Grouped uitableview has 20px of extra padding at the bottom
这些老系统代码,是猪写的么?
直接选择排序和快速排序