I need an update query with a WHERE statement, but if the record does not exist it should insert the data.
e.g. UPDATE table SET this = 'that', that = 'this' WHERE this = 'this' AND that = 'that'
I don't have an unique value, I have 2 columns that can't occur 2 times or more. Let me give you an example:
I've got a table:
Column1 | Column2 | Column3
---------------------------
1 | 2 | 500
1 | 3 | 500 This is OK because column2 is other than above
2 | 2 | 500 ALSO OK because column1 is other than above!
1 | 2 | 500 NOT OK! Already exists -> need update for Column3! needs to be 1000 now!
As you can see in the table, the two columns can occur more than once!
Is there a function for this? Or should I first check if there is a record? I do not have an Unique key
, so I can't use this.