You must set the field to primary key (PRIMARY key or UNIQUE constraint (unique) by using the following two methods.
1: Use Replace into (this method is to take advantage of the substitution method, a bit like a class in the first delete and then insert)
Copy Code code as follows:
REPLACE into Syntax
REPLACE [Low_priority | Delayed]
[Into] tbl_name [(Col_name,...)]
{VALUES | VALUE} ({expr | DEFAULT},...), (...),...
Pre
REPLACE [Low_priority | Delayed]
[Into] Tbl_name
SET col_name={expr | DEFAULT}, ...
Pre
REPLACE [Low_priority | Delayed]
[Into] tbl_name [(Col_name,...)]
SELECT ...
2: Use Insert [IGNORE] into (this method is more efficient, to determine whether there is not inserted, otherwise inserted)
Copy Code code as follows:
INSERT [IGNORE] into Syntax
INSERT [Low_priority | Delayed | High_priority] [IGNORE]
[Into] tbl_name [(Col_name,...)]
{VALUES | VALUE} ({expr [...]