mysql json类型
2021/9/5 2:06:11
本文主要是介绍mysql json类型,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
表
CREATE TABLE `t_json` (
`id` int NOT NULL AUTO_INCREMENT,
`json` json DEFAULT NULL,
`jarray` json DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
数据
查询
select sum(json->'$.oilFee') +sum(json->'$.partFee') + IFNULL(sum(json->'$.paratFee'),0), json->'$.remark' from t_json where json->'$.remark' is null; // 查json字段 ->'$.字段名'
select * from t_json where 1 member of (jarray) // 对json数组进行查找
select * from t_json where JSON_CONTAINS_PATH(json, 'all', '$.remark') // 查询json数据中存在remark键的数据. 其中all是条件,可以是one或all
update t_json set json = '{\"test\": \"test\"}' where id = 1;
这篇关于mysql json类型的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04package.json 文件位置在哪?-icode9专业技术文章分享
- 2024-10-01Craco.js学习:从入门到实践指南
- 2024-10-01Create-React-App学习:入门与实践指南
- 2024-10-01CSS-in-JS学习:从入门到实践指南
- 2024-09-30JSX语法学习:从入门到初步掌握
- 2024-09-30Mock.js学习:入门教程与实战演练
- 2024-09-30React Hooks学习:从入门到实践
- 2024-09-30受控组件学习:React中的基础入门教程
- 2024-09-29JS定时器教程:初学者必看指南
- 2024-09-29JS对象教程:初学者的全面指南