When inserting data in MYSQL, duplicate data is ignored. when inserting data in the program, existing data is not inserted, and non-existing data is inserted. You can use the stored procedure or not exists to determine whether the stored procedure EXISTS. When using the following two methods, the field must be set to "primary key" or "UNIQUE constraint (UNIQUE )".
1: Use replace into (This method uses the replacement method, which is a bit similar to deleting and then inserting) replace into Syntax REPLACE [LOW_PRIORITY | DELAYED] [INTO] tbl_name [(col_name,...)] {VALUES | VALUE} ({expr | DEFAULT },...), (...),... Or: REPLACE [LOW_PRIORITY | DELAYED] [INTO] tbl_name SET col_name = {expr | DEFAULT },... Or: REPLACE [LOW_PRIORITY | DELAYED] [INTO] tbl_name [(col_name,...)] SELECT... 2: Use INSERT [IGNORE] INTO (this method is highly efficient and can be used to determine whether it exists or not. Otherwise, it will be inserted) INSERT [IGNORE] INTO Syntax INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] {VALUES | VALUE} ({expr [...]