This article mainly introduces the relevant information about the detailed explanation of the replace into instance of mysql. Friends in need can refer to the detailed explanation of the replace into instance of
##mysql
replace into has a similar function to insert. The difference is that replace into first tries toinsert data into the table.
1. If it is found that this row of data already exists in the table (judged based on the primary key or unique index ), first delete this row of data, and then insert new data.
It should be noted that the table into which data is inserted must have a primary key or a unique index! Otherwise, replace into will insert data directly, 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, ...
SELECT LAST_INSERT_ID() from dual
The above is the detailed content of Detailed explanation of replace into example of mysql. For more information, please follow other related articles on the PHP Chinese website!