title: MySQL Trigger: Delete From Table AFTER DELETE
body: <p>Scope: Two tables.  When a new patron is created, they have some information about them stored into a 2nd table (This was done using a trigger as well, it works as expected). Here's an example of my table structure and relationship.</p>
  
  <p>Table 1-> <strong>patrons</strong></p>
  
  <pre><code>+-----+---------+-----+
  +  id +   name  + val +
  +=====+=========+=====+
  +  37 +  george +  x  +
  +-----+---------+-----+
  +  38 +  sally  +  y  +
  +-----+---------+-----+
  </code></pre>
  
  <p>Table 2 -> <strong>patron_info</strong></p>
  
  <pre><code>+----+-----+----------+
  + id + pid +   name   +
  +----+-----+----------+
  +  1 +  37 +  george  +
  +----+-----+----------+
  +  2 +  38 +  sally   +
  +----+-----+----------+
  </code></pre>
  
  <p>The administrator can manage the patrons. When they choose to remove a patron, the patron is removed from the <strong>table 1</strong> <code>patrons</code>. At this point, nothing happens to <strong>table 2</strong> <code>patron_info</code>. </p>
  
  <p>I'm simply trying to create a trigger to delete from table 2, when table 1 has an item deleted. Here's what I've tried...</p>
  
  <p>Initially, I try to drop the trigger if it exists (just to clear the air)...</p>
  
  <pre><code>DROP TRIGGER IF EXISTS log_patron_delete;
  </code></pre>
  
  <p>Then I try to create the trigger afterwards...</p>
  
  <pre><code>CREATE TRIGGER log_patron_delete AFTER DELETE on patrons
  FOR EACH ROW
  BEGIN
  DELETE FROM patron_info
      WHERE patron_info.pid = patrons.id
  END
  </code></pre>
  
  <p>At this point, I get a syntax error <code>1046: Check syntax near END on line 6</code>. I don't know what the error is at this point. I've tried several different variations. Also, am I required to use a delimiter here?</p>
  
  <p>Can anyone help restore my sanity?</p>