1, MySQL special syntax
2. Solved problems
When insert data encounters a unique key constraint (primary key or unique index), perform a change operation for the specified field. If ON DUPLICATE KEY UPDATE is specified at the end of the INSERT statement and DUPLICATE values appear in a UNIQUE index or PRIMARY KEY, perform UPDATE ON the row where DUPLICATE values appear. Insert a new row if it does not cause problems with duplicate columns of unique values.
3, SQL example
INSERT INTO classes (_id,password)
VALUES
('1','aaaa') ,
('2','bbbb')
ON DUPLICATE KEY UPDATE
password = VALUES(password)
Copy the code