通过json_set函数,来修改data字段的值
SELECT REPLACE(json_extract(param,'$.payFundAcc'),'"','') from t_external_trade_event where status != 'S' ;
mysql> update tab_json set data = json_set(data,"$.address","Guangzhou") where id = 1; #对id = 1的行的address的键值进行修改.
Query OK, 1 row affected (0.26 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from tab_json;
+----+--------------------------------------------------------------+
| id | data |
+----+--------------------------------------------------------------+
| 1 | {"tel": 13249872314, "name": "Mike", "address": "Guangzhou"} |
| 2 | {"tel": 189776542, "name": "David", "address": "Shanghai"} |
+----+--------------------------------------------------------------+
rows in set (0.00 sec)
mysql> update tab_json set data = json_set(data,"$.address","Shenzhen");
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> select * from tab_json;
+----+-------------------------------------------------------------+
| id | data |
+----+-------------------------------------------------------------+
| 1 | {"tel": 13249872314, "name": "Mike", "address": "Shenzhen"} |
| 2 | {"tel": 189776542, "name": "David", "address": "Shenzhen"} |
+----+-------------------------------------------------------------+
rows in set (0.00 sec)
mysql> update tab_json set data = json_set(data,"$.address","Hangzhou") where id = 2; #对id为2的address键值进行修改
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from tab_json;
+----+-------------------------------------------------------------+
| id | data |
+----+-------------------------------------------------------------+
| 1 | {"tel": 13249872314, "name": "Mike", "address": "Shenzhen"} |
| 2 | {"tel": 189776542, "name": "David", "address": "Hangzhou"} |
+----+-------------------------------------------------------------+
rows in set (0.00 sec)
mysql> update tab_json set data = json_set(data,"$.passcode","654567") where id = 1; #对id为1的passcode字段进行修改,发现没有这个键值,就增加了一个键值对.
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from tab_json;
+----+-----------------------------------------------------------------------------------+
| id | data |
+----+-----------------------------------------------------------------------------------+
| 1 | {"tel": 13249872314, "name": "Mike", "address": "Shenzhen", "passcode": "654567"} |
| 2 | {"tel": 189776542, "name": "David", "address": "Hangzhou"} |
+----+-----------------------------------------------------------------------------------+
rows in set (0.00 sec)
mysql> update tab_json set data = json_set(data,"$.olds","12") where id = 2;
Query OK, 1 row affected (0.17 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from tab_json;
+----+-----------------------------------------------------------------------------------+
| id | data |
+----+-----------------------------------------------------------------------------------+
| 1 | {"tel": 13249872314, "name": "Mike", "address": "Shenzhen", "passcode": "654567"} |
| 2 | {"tel": 189776542, "name": "David", "olds": "12", "address": "Hangzhou"} |
+----+-----------------------------------------------------------------------------------+
rows in set (0.00 sec)
mysql> update tab_json set data = json_set(data,"$.age","33");
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> select * from tab_json;
+----+------------------------------------------------------------------------------------------------+
| id | data |
+----+------------------------------------------------------------------------------------------------+
| 1 | {"age": "33", "tel": 13249872314, "name": "Mike", "address": "Shenzhen", "passcode": "654567"} |
| 2 | {"age": "33", "tel": 189776542, "name": "David", "olds": "12", "address": "Hangzhou"} |
+----+------------------------------------------------------------------------------------------------+
rows in set (0.00 sec)
通过json_set函数,来修改data字段的值的更多相关文章
- vue手写的轮播图片,解决已经修改data中的值,页面标签已绑定,但页面没效果
1.效果 2.index.html <!DOCTYPE html> <html lang="en"> <link> <meta chars ...
- update修改某个字段的值
---恢复内容开始--- 例:给表名 ecs_article中 content字段 的 /tianyuan 替换成 11 加where条件:UPDATE ecs_article set conten ...
- 通过java反射机制,修改年龄字段的值
需求:将生日转为年龄 /** * 获取年龄值 */ public List getAgeInfo(List list) throws Exception { if (null == list || l ...
- SQL 批量修改一个字段的值为另一个字段的值
AND create_time BETWEEN '2016-07-25 14:30:00' AND '2016-07-25 15:20:28'; AND create_time BETWEEN '20 ...
- mysql数据库中,如何对json数据类型的值进行修改?通过json_set函数对json字段值进行修改?
需求描述: 今天在看mysql中存放json数据类型的问题,对于json数据进行修改的操作, 在此记录下. 操作过程: 1.创建包含json数据类型的表,插入基础数据 mysql> create ...
- sqlservice 查询该字段的值是否为数字、不包含a-z字母、获取中文的首字母
select zjm from xskh where guid_yw='e6ee44f3-98ab-4446-bd9b-db2e525d3b24' and zjm not like '%[ABCDE ...
- 如何自动拼接 Update语句,仅Update已修改的字段
我们通常使用update语句更新数据库记录,例如使用update user set username='001', nickname='Tom', age=18 where id = 1语句更新use ...
- MySQL 分区表 partition线上修改分区字段,后续进一步学习partition (1)
公司线上在用partition,有一个表的分区字段错了,需要重建,结果发现没有办法像修改主键字段或者修改索引字段那样直接一条sql搞定.而是需要建临时表,有down time,所以去仔细看了文档,研究 ...
- PDF.NET+EasyUI实现只更新修改的字段
PDF.NET 在我看来是目前最简单易用而且高效的orm框架之一,感谢作者深蓝医生 实现的功能是easyui的行内编辑,用到了爱看书不识字的datagrid仿extjs的行内编辑 都是牛人啊. 201 ...
随机推荐
- postman测试API
首先创建环境变量 再次在请求参数中,可以应用环境变量,只需要在地址中引用环境变量即可 将返回的参数设置到环境变量中 如已经设置好环境变量,在认证中,选择Bearer Token,然后设置Token为环 ...
- Tomcat重启Shell脚本
--测试通过 vim restart_tomcat.sh#!/bin/bash# Filename: restart_tomcat.sh# Description: Restart tomcat# D ...
- 使用C语言 判断当前网络是否联通
方式一: int GetNetStat( ) { char buffer[BUFSIZ]; FILE *read_fp; int chars_read; int ret; try { memset( ...
- osg fbx 模型树结构
void Test::printOsgGroup(osg::ref_ptr<osg::Group> &groupParam) { qDebug() <<groupPar ...
- PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)
1061 Dating (20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...
- SUBMIT标准程序取ALV数据
示例1: 调用J3RFLVMOBVEDH ,取物料的期初/ 期末庫存数.金额 FORM frm_call_j3rflvmobvedh. DATA: lr_bukrs TYPE RANGE OF buk ...
- DELPHI中 screen.Cursor:=crhourglass; adoQuery.close; adoquery.Open; screen.Cursor:=crdefault;啥意思
鼠标忙这段代码大概是用来演示鼠标的用法的.具体解释如下: 使鼠标指针为沙漏状.(以表示程序正忙)screen.Cursor:=crhourglass; 把(打开的)数据库关闭.adoQuery.clo ...
- Hive实现WordCount详解
一.WordCount原理 初学MapReduce编程,WordCount作为入门经典,类似于初学编程时的Hello World.WordCount的逻辑就是给定一个/多个文本,统计出文本中每次单词/ ...
- 使用PHP实现命令模式(转)
<?php /** * 命令模式 2010-08-21 sz * @author phppan.p#gmail.com http://www.phppan.com * 哥学社成员(http:// ...
- IDA7.2破解版本
更新说明 https://www.hex-rays.com/products/ida/7.2/index.shtml 破解文章 作者阐述了一下对IDA安装密码的攻击方法,通过枚举多种语言默认的随机数发 ...