title: Trigger (MYSQL) with if-then-else doesn't works
body: <p>I have this trigger that <strong>doesn't insert or update the &quot;privilegio&quot;</strong> and it <strong>doesn't give errors</strong> in the log</p>
  <pre><code>delimiter //
  
  CREATE TRIGGER Privilegio_Pagamento AFTER insert
  ON pagamento FOR EACH ROW
  BEGIN
      declare numero int(8);
      declare ordutente varchar(64);
      
      select count(*) into numero from pagamento where ordinante = new.ordinante and opera = new.opera;
      select username into ordutente from utente where email = new.ordinante;
      if (numero &lt;&gt; 0) then
          update privilegio P set P.volumi = concat(P.volumi, '-', new.volumi) where opera = new.opera and utente = ordutente;
      else 
          insert into privilegio(utente, opera, volumi) values(ordutente, new.opera, new.volumi);
      end if;
  END
  </code></pre>
  <p>The interesting thing is that <strong>each single line works alone</strong> (the selects, the updates, the insert) so it seems that <strong>what fails is the if-then-else</strong>, since if I use something like this</p>
  <pre><code>delimiter //
  
  CREATE TRIGGER Privilegio_Pagamento AFTER insert
  ON pagamento FOR EACH ROW
  BEGIN
      declare numero int(8);
      declare ordutente varchar(64);
  
      select count(*) into numero from pagamento where ordinante = new.ordinante and opera = new.opera;
      select username into ordutente from utente where email = new.ordinante;
      insert into privilegio(utente, opera, volumi) values(ordutente, new.opera, new.volumi);
  END
  </code></pre>
  <p>It adds the the &quot;privilegio&quot;.</p>
  <p>To be sure I also tried this</p>
  <pre><code>select if (((select count(*) from pagamento where ordinante = 'abel.ligure73@virgilio.it' and opera = 'Problema Grande e Dama Rossa') &lt;&gt; 0), 'yes', 'no')
  </code></pre>
  <p>and <strong>this works</strong>.
  What could be the problem?</p>
  <p><strong>EDIT</strong></p>
  <p>The answer of Gordon Linoff is correct but for my purpose it needs a concat like this <code>concat(volumi, '-', new.volumi)</code>.
  Hope someone else will find it useful!</p>