Detailed explanation of replace into example in mysql replace into is similar to insert, except that replace into first tries to insert data into the table. 1. If it is found that this row of data already exists in the table (determined by the primary key or unique index), delete this row of data first, and then insert the new data. 2. Otherwise, insert new data directly. Please note that the table into which data is inserted must have a primary key or a unique index! Otherwise, replace into will directly insert the data, which will result in duplicate data in the table. There are three ways to write replace into in MySQL: The code is as follows: replace into table(col, ...) values(...) replace into table(col, ...) select ... replace into table set col=value, ... Extension: mysql gets the last primary key corresponding to the insertion (generally users get the primary key order number of the order table) SELECT LAST_INSERT_ID() from dual Thank you for reading, I hope it can help you, thank you for your support of this site! You may also be interested in:
|
<<: JavaScript implements countdown on front-end web page
>>: Linux kernel device driver Linux kernel basic notes summary
When we develop a single-page application, someti...
This article shares the specific code of js to ac...
I've seen people asking before, how to add sty...
Table of contents Find and fix table conflicts Up...
This article shares the specific process of the j...
SQL statement DROP TRIGGER IF EXISTS sys_menu_edi...
This article shares the implementation code of jQ...
1. Flex is the abbreviation of Flexible Box, whic...
This article example shares the specific code for...
I was recently writing a lawyer recommendation we...
Data is the core asset of an enterprise and one o...
MySQL supports many types of tables (i.e. storage...
In the vertical direction, you can set the alignm...
Discuz! Forum has many configuration options in th...
MySQL download and installation (version 8.0.20) ...