Insert data and if already inserted then update in sql

后端 未结 7 3110
眼角桃花
眼角桃花 2021-02-20 13:18

I simply want to insert the data to a SQL database table and if there is some data inserted already then I want to update that data. How can I do this using Java. Kindly help me

7条回答
  •  一个人的身影
    2021-02-20 13:49

    Just identify the unique item in your data set (like Id or a code). Then by using that try to do a SELECT query first. If the Resultset is empty, do the INSERT else try to UPDATE the details.

提交回复
热议问题