title: Use a trigger to stop an insert or update
body: <p>Since MySQL ignores check constraints, how does one go about using a trigger to stop an insert or update from happening?</p>
  
  <p>For example:</p>
  
  <p>Table foo has an attribute called agency, and the agency attribute can only be 1, 2, 3, 4, or 5.</p>
  
  <pre><code>delimiter $$
  create trigger agency_check
  before insert on foo
  for each row
  begin
  if (new.agency &lt; 1 or new.agency &gt; 5) then
  
  #Do nothing?
  
  end if;
  end
  $$
  delimiter ;
  </code></pre>
  
  <p>Or is there a better way to go about doing check constraints in MySQL?</p>