I want to implement an insertion function. Before inserting, it is judged whether there is the same data as the key field in the database. If so, perform the modification operation. If not, perform the insert operation. I would like to ask for advice: Is there any way to do it? You can query and judge by yourself, can you complete the whole process by calling directly? Is there a similar method in mybatis?
There is on duplicate key update in mysql, just create a unique index for the key field
mybatis
应该没有这样的条件控制, 只能看数据库有没有类似的条件控制, 如果是oracle
可以用merge into using (subquery) on (condition) when matched then update (update statement) when not matched then insert (insert statement)
Can I use mysql’s replace into?