How to prevent to insert duplicate value in sqlite database (if duplicate then overwrite)

前端 未结 6 1275
余生分开走
余生分开走 2021-01-05 15:34

I had created two table in my database, In both table I am inserting value at the same time, now what I want to do is that, I want to insert record in second table, but the

6条回答
  •  情深已故
    2021-01-05 16:36

    Use the following query

    INSERT OR REPLACE INTO table_name (idColoumn, categoryColumn) VALUES (?, ?)
    

    It will add new row if it does not exist or update row if it exists. hope this will help you.

提交回复
热议问题