title: trigger after insert delete query not working
body: <p>I am writing trigger to work after insert and check if count records more than 500   make delete one record but not work this trigger  </p>
  
  <pre><code>CREATE TRIGGER `delrecord` after insert on `tbl_coins`
  FOR EACH ROW
  BEGIN
  DECLARE recordcount INT;
  DECLARE deleterecordcount INT;
  
  set recordcount = (select count(*) from tbl_coins);
  
  if recordcount &gt; 500
  
  then
  set deleterecordcount = (select ID from tbl_coins order by time asc   limit 1);
  
  delete from tbl_coins 
  
  where ID = deleterecordcount;
  
  end if;
  END
  </code></pre>