title: Trigger to insert percentage value in a table based on the values of two different fields
body: <p>I have a table 'attendance' having 3 fields 'class_total','class_attended' and 'attendance_percent'.
  I want to insert/update the value of 'attendance_percent' whenever values are inserted/updated in the fields 'class_total' and 'class_attended' by (class_attended/class_total)*100.
  For this I am using the trigger:</p>
  
  <pre><code>CREATE TRIGGER percent_update
  BEFORE INSERT ON attendance
  FOR EACH ROW
  SET NEW.attendance_percent =(attendance.class_attended/attendance.class_total)*100 ;
  </code></pre>
  
  <p>But its not working.</p>