当前位置:网站首页>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
边栏推荐
- . NETCORE sets the API post mode, which can accept parameters directly in parentheses
- Blazor University (12) - component lifecycle
- 类似Jira的十大项目管理软件
- 2022T电梯修理考试模拟100题及在线模拟考试
- 2022年度Top9的任务管理系统
- 通过 zxing 生成二维码
- Use of slice grammar sugar in C #
- 手机连接电脑后,QT的QDIR怎么读取手机文件路径
- [mock data] fastmock dynamically returns the mock content according to the incoming parameters
- Preview of converting doc and PDF to SWF file
猜你喜欢

Xamarin effect Chapter 21 expandable floating operation button in GIS

2022 P cylinder filling training test questions and simulation test

IOTOS物联中台对接海康安防平台(iSecure Center)门禁系统

12.<tag-链表和常考点综合>-lt.234-回文链表

二进制文件版本控制工具选择难?看完这篇你会找到答案

Peut recevoir plusieurs paramètres de type de données - paramètres variables

Impact of AOT and single file release on program performance

Huawei mobile ADB devices connection device is empty

Why is bi so important to enterprises?

2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination
随机推荐
Peut recevoir plusieurs paramètres de type de données - paramètres variables
Xamarin effect Chapter 21 expandable floating operation button in GIS
Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
2022年P气瓶充装培训试题及模拟考试
Miniapi of. Net7 (special section): NET7 Preview3
软件测试相关知识~
【VS Code】解决jupyter文件在vs code中显示异常的问题
Find the number of leaf nodes of binary tree
Comprehensive calculation of employee information
Swap the left and right of each node in a binary tree
一文了解全面静态代码分析
二进制文件版本控制工具选择难?看完这篇你会找到答案
Use of slice grammar sugar in C #
Xutils3 corrected a bug I reported. Happy
Improvement of ref and struct in C 11
WinForm allows the form form to switch between the front and active states
JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
Yes Redis using distributed cache in NE6 webapi
svg标签中利用<polygon/>循环数组绘制多边形
PID debugging of coding motor (speed loop | position loop | follow)