how to use if not exists while inserting a row mysql

后端 未结 3 2054
我寻月下人不归
我寻月下人不归 2021-01-24 08:17

The thing that i want to do is to check if there is a same row and if not to insert a new row to the table.

In that case, how can i use if not exists ?

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-24 09:20

    You can use the INSERT IGNORE INTO ... syntax. When using this, duplicate key errors are treated as warnings and the statement will return without having inserted the affected row.

提交回复
热议问题