title: mysql trigger auto calculate age from dob and create age field insert data
body: <pre><code>DELIMITER $$
  
  CREATE TRIGGER example
       BEFORE INSERT ON dates FOR EACH ROW
       BEGIN
       declare age int;
            IF ((set age = AND (select * , year(curdate())-year(dob) ) &lt; 18)
            THEN
                 CALL `'Cannot add or update row: only one active row allowed per type'`;
            END IF;
       END;
  $$
  </code></pre>