title: SQL update if exist and insert else and return the key of the row
body: <p>I have a table named WORD with the following columns<br></p>
  
  <pre><code>WORD_INDEX INT NOT NULL AUTO_INCREMENT,
  CONTENT VARCHAR(255),
  FREQUENCY INT
  </code></pre>
  
  <p>What I want to do is when I try to add a row to the table if a row with the same CONTENT exits,  I want to increment the FREQUENCY by 1. Otherwise I want to add the row to the table. And then the WORD_INDEX in the newly inserted row or updated row must be returned.<br>
  I want to do this in H2 database from one query.<br>
  I have tried 'on duplicate key update', but this seems to be not working in H2.</p>
  
  <p><br>PS- I can do this with 1st making a select query with CONTENT and if I get a empty result set, makeing insert query and otherwise making a update query. But as I have a very large number of words, I am trying to optimize the insert operation. So what I am trying to do is reducing the database interactions I am making.</p>