title: MariaDB sql trigger to update if key exists or insert if doesn't exist?
body: <p>I'm new to SQL, but trying to build a simple trigger that will execute on each insertion. I want it to update some table values if the key already exists, or insert it with some new values if it doesn't exist. </p>
  
  <p>Below is what I have attempted, but I would ideally want tester to be the thing that is being inserted. Something like NEW.reference_key?</p>
  
  <pre><code>CREATE TRIGGER key_access_monitor 
  BEFORE INSERT ON individual_key_log 
  FOR EACH ROW 
  BEGIN
      IF EXISTS (SELECT reference_key FROM individual_key_log WHERE key = 'tester')
          SELECT 'Found it!'
      ELSE
      SELECT 'Cannot find it!'
     END IF
  END
  </code></pre>