当前位置:网站首页>MySQL insert \ pre update + judgment condition
MySQL insert \ pre update + judgment condition
2022-07-01 01:50:00 【Changchun bully】
1、mysql Operation to determine whether data exists before inserting
INSERT INTO table(field1, field2, fieldn) SELECT 'field1',
'field2', 'fieldn' FROM DUAL WHERE NOT EXISTS(SELECT field FROM
table WHERE field = ?)
2、 Insert if it doesn't exist , If it exists, it will be updated
If the inserted data will cause UNIQUE Index or PRIMARY KEY conflict / repeat , execute UPDATE sentence
INSERT INTO `student`(`name`, `age`) VALUES('Jack', 19)
ON DUPLICATE KEY
UPDATE `age`=19;
-- If will happen conflict, the update statement is executed 2 row(s) affected
3、 If the inserted data will cause UNIQUE Index or PRIMARY KEY conflict / repeat , Delete the old data first and then insert the latest data
REPLACE INTO `student`(`name`, `age`) VALUES('Jack', 18);4、 Avoid repeated insertion
keyword / sentence :insert ignore into, If the inserted data will cause UNIQUE Index or PRIMARY KEY conflict / repeat , Ignore this operation / Don't insert data
INSERT IGNORE INTO `student`(`name`, `age`) VALUES('Jack', 18);
-- 0 row(s) affected边栏推荐
- Mathematical knowledge: 01 sequence satisfying conditions - find combinatorial number
- 【Content-Type请求头的内容】
- 正向代理和反向代理快速理解
- TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to
- What are the preferential activities for stock account opening? In addition, is it safe to open a mobile account?
- C#生成putty格式的ppk文件(支持passphrase)
- 机器学习9-通用逼近器径向基函数神经网络,在新观点下审视PDA和SVM
- laravel+redis 生成订单号-当天从1开始自增
- Microbiological health, why is food microbiological testing important
- gin_ gorm
猜你喜欢

45 year old programmer tells you: why do programmers want to change jobs? It's too true

关于白盒测试,这些技巧你得游刃有余~

Test essential tool - postman practical tutorial

Institute of Microbiology, commonly used biochemical reactions in microbiological testing
2022年最新csdn涨薪技术栈-app自动化测试概述

Microbiological health, why is food microbiological testing important

FL Studio20.9水果软件高级中文版电音编曲
![[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大](/img/fa/f9bad44147ba9af21183b7bd630e32.png)
[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大

测试必备工具—Postman实战教程

go导入自建包
随机推荐
3500 word summary: a complete set of skills that a qualified software testing engineer needs to master
PHP通过第三方插件爬取数据
New opportunities for vr/ar brought by metauniverse
小程序中实现excel数据的批量导入
Sort custom function
There is no future to be expected. It is just the last fantasy of a migrant worker before he dies
P6773 [NOI2020] 命运(dp、线段树合并)
Working for eight years as a programmer, but with a salary of three years after graduation, it's too late to be enlightened again
小程序云开发之--微信公众号文章采集篇
The whole process of AS400 API from zero to one
微生物健康,食品微生物检测为什么很重要
laravel Carbon 时间处理类使用
Composants de la grille de données portatifs
Selenium classic interview question - multi window switching solution
1500w播放下还藏着什么热点?B站2个未来趋势你不得错过
[dynamic planning] path dp:931 Minimum Falling Path Sum
微生物检测,土壤微生物的作用有哪些?
Sun Yuchen told Swiss media Bilan that the bear market will not last long
【Proteus仿真】Arduino UNO +74C922键盘解码驱动4X4矩阵键盘
Compile and install oh my Zsh