Determine whether a record already exists before inserting a SQL statementINSERT INTO test(A,B) select 'ab',2 WHERE NOT EXISTS (SELECT * FROM test WHERE A='ab'); Simple collection of judgments when inserting sqlWhen the user module or other modules require database uniqueness, you need to first determine whether the data already exists in the database before inserting it; This is the most basic SQL insert statement. ```sql ```sql INSERT INTO user(name,password) values(admin,123456) Next, transform it into inserting to determine whether #{parameter} exists ```sql INSERT INTO user(name, password) SELECT #{admin},#{123456} FROM DUAL WHERE NOT EXISTS (SELECT name,password FROM user WHERE name= #{admin} and password= # {123456}); `` This is done, the query return value = 0 means failure = 1 means success The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: The most comprehensive collection of front-end interview questions
>>: How to draw a vertical line between two div tags in HTML
This article shares with you a uniform motion imp...
As one of the most popular front-end frameworks, ...
1. When the mobile terminal processes the list sl...
There are two common ways to make div background ...
Table of contents Rendering API changes Render fu...
This article shares the specific code for JavaScr...
Table of contents 1. Closure 2. Closure usage sce...
Table of contents Oracle Isolation Levels MySQL I...
Overview In zabbix version 5.0 and above, a new f...
Table of contents 1. List traversal 2. The role o...
Customizing images using Dockerfile Image customi...
Sometimes you need to debug remotely in a server ...
There are four main MySQL string interception fun...
Table of contents Cache function in vue2 Transfor...
This article example shares the specific code of ...