当前位置:网站首页>There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
2022-04-23 03:18:00 【JavaTestZhangy】
INSERT IGNORE INTO table(aaa,bbb)
SELECT '1111','2222' FROM DUAL
WHERE NOT EXISTS(
SELECT id FROM table WHERE bbb= '2222'
)
mybaits
<insert id="addItemCharacteristic" parameterType="com.orderalliance.entity.CharacteristicDTO">
<!--INSERT INTO table (item_id,characteristic) VALUES(#{aaa,jdbcType=BIGINT},#{bbb,jdbcType=VARCHAR})-->
<!-- this sql Statement to prevent repeated addition of data -->
INSERT IGNORE INTO table (aaa,bbb)
SELECT #{111,jdbcType=BIGINT},#{222,jdbcType=VARCHAR} FROM DUAL
WHERE NOT EXISTS(
SELECT id FROM table WHERE bbb= #{bbb,jdbcType=VARCHAR}
)
</insert>
Key code
INSERT IGNORE INTO Table name (' Field ')
SELECT ' Data when the field needs to be inserted ' FROM dual
WHERE NOT EXISTS
(SELECT * FROM ' Table name ' WHERE ' Fields that need to be restricted from repetition ' = ' Restricted field the data inserted this time ')
key word
IGNORE
NOT EXISTS
版权声明
本文为[JavaTestZhangy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230314477260.html
边栏推荐
- Why is bi so important to enterprises?
- Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
- General testing technology [1] classification of testing
- 数据挖掘系列(3)_Excel的数据挖掘插件_估计分析
- A comprehensive understanding of static code analysis
- Charles uses three ways to modify requests and responses
- LoadRunner - performance testing tool
- Mysql database design specification
- The most easy to understand dependency injection and control inversion
- C language to achieve address book - (static version)
猜你喜欢
手机连接电脑后,QT的QDIR怎么读取手机文件路径
Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
[new version release] componentone added Net 6 and blazor platform control support
Use of slice grammar sugar in C #
The most understandable life cycle of dependency injection
超好用的Excel异步导出功能
Xutils3 corrected a bug I reported. Happy
《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
ASP. Net and ASP NETCORE multi environment configuration comparison
Fight leetcode again (290. Word law)
随机推荐
Yes Redis using distributed cache in NE6 webapi
svg标签中利用<polygon/>循环数组绘制多边形
ThreadLocal 测试多线程变量实例
How does Microsoft solve the problem of multiple PC programs
Aspnetcore configuration multi environment log4net configuration file
Detailed explanation of socket programming send() and recv() functions
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
OLED multi-level menu record
MySQL索引详解【B+Tree索引、哈希索引、全文索引、覆盖索引】
socket編程 send()與 recv()函數詳解
be based on. NETCORE development blog project starblog - (2) environment preparation and creation project
可以接收多種數據類型參數——可變參數
[MySQL] left Function | Right Function
类似Jira的十大项目管理软件
Mysql database
2022a special equipment related management (elevator) work license question bank and simulation examination
C language to achieve address book - (static version)
2022T电梯修理考试模拟100题及在线模拟考试
JSON related
Explanation keyword of MySQL