mysql insert error 1062

后端 未结 5 1320
名媛妹妹
名媛妹妹 2020-12-04 04:31

SQL query:

INSERT INTO  `website_categorization`.`category_keyword` (
`ID` ,
`ID_Category` ,
`Keyword` ,
`Score`)
VALUES (
NULL ,  \'18\',  \'free mail\',  \         


        
5条回答
  •  离开以前
    2020-12-04 04:58

    You already have a row in your database with the values '18' and 'free mail'. You can't have two such rows because of the unique constraint. You have some choices:

    • Remove the original row and try your insert again: DELETE FROM yourtable WHERE ID_Category = '18' AND Keyword = 'free mail'.
    • Remove the unique constraint to allow both rows to exist.
    • Use INSERT IGNORE to ignore the error.
    • Use REPLACE instead of INSERT to replace the old row with the new row.
    • Attempt the INSERT knowing that the client-side will be alerted of the error.

提交回复
热议问题