Imagine a table that maps from a string to two integers. I would like to either insert a new row if the key is not in the table, or update the existing row by adding up the integers (key, oldx+x, oldy+y). I'll be doing this a lot and I wonder if I can do this in one operation instead of first SELECT to check if the row exists and then INSERT or UPDATE with the sum as this probably will result in two lookups.
I'm new to SQL and I can't figure how to do this in an efficient way.
 
     
     
     
     
    