I am using mysql Nodejs package but I will tag this question as mysql only as people with mysql knowledge should be able to help me out.
This question is more about finding an efficient way to write a query.
I have a table with a composite key of partID
,orderID
and stageID
.
I need to insert into this table if there are no previous composite key else update the other fields if a row with these composite keys were found.
I was going to do a select query where condition of these 3 columns and then in case of a result do an update else do an insert.
Is this the best way to handle this situation. Sorry I do not have much experience with SQL databases.