title: how to check if row exist with trigger in mysql?
body: <p>I want to check if a row exist with a trigger before insert here is my table and my trigger </p>
  
  <p>Table students: ID | Name </p>
  
  <p>Trigger validation : </p>
  
  <pre><code>CREATE TRIGGER `validation` BEFORE INSERT ON `students` 
  FOR EACH ROW 
  begin
  
  declare var_name varchar(255);
  declare check_row varchar(255);
  
  set var_name = new.name;
  select name into check_row from students where name = var_name;
  
  end
  </code></pre>