Insert statement that checks for duplicate before insert

后端 未结 6 1874
一个人的身影
一个人的身影 2020-12-17 05:00

I need to make a insert but only if similar record don\'t exists
for example:

INSERT INTO requests (\'user_id\',\'subject\',\'text\',\'time\') V

6条回答
  •  长情又很酷
    2020-12-17 05:16

    Replace your query from

    INSERT INTO requests ('user_id','subject','text','time') VALUES (56,'test','test 1234',6516516)

    To,

    REPLACE INTO requests ('user_id','subject','text','time') VALUES (56,'test','test 1234',6516516)

    This will add a small delay to the execution, but it is more efficient than any other method

提交回复
热议问题