title: How can i create a trigger to verify if a record exists on another table?
body: <p>I am using version 5.0 of mysql.</p>
  
  <p>I'm trying to create a trigger to check if one entry(name of Food) exists in the other table.</p>
  
  <p>I´ve done this:</p>
  
  <pre><code>delimiter //
  CREATE TRIGGER verifyExists BEFORE INSERT ON Sold
      FOR EACH ROW
      BEGIN
          IF NEW.nameF not in (
              select A.nameF
              From Available D
              where (NEW.nameF = A.nameF and NEW.nameR = A.nameR)
          )
          END IF;
      END;
  //
  delimiter ; 
  </code></pre>
  
  <p>this doesen't work, why?</p>