title: Error when creating a procedure with some parameters of input, and insert later in DB, after a validation in MYSQL
body: <p>My problem is this, I am trying to create a procedure that receives input parameters and check if the data exists or not, to be able to insert in one table or another.
  I have tried in different ways and I can not find the error that appears in the syntax of the declaration.</p>
  
  <p>Please I need help.</p>
  
  <p>A thousand thanks in advance.</p>
  
  <p>/ * Next I show the code of the procedure * /</p>
  
  <pre><code>DELIMITER //
  
  CREATE PROCEDURE InsertMensaje(IN pNOMBRE varchar(50), IN pTLFN varchar(9), IN pEMAIL varchar(50), IN pASN varchar(15), IN pMSG varchar(500))
  
  BEGIN
  
      /*declare valiable*/
      DECLARE vIDCLI int;
  
  /*THESE OPTIONS I HAVE ALSO TESTED*/
  /*SET vIDCLI = (select id_cliente from tb_cliente where email = pEMAIL);*/
  /*select id_cliente into vIDCLI from tb_cliente where email = pEMAIL;*/
  
  /* DECLARE vAUX varchar(50)*/ 
  /* SET vAUX = (select email from tb_cliente where email = pEMAIL);*/
  /* select email into vAUX from tb_cliente where email = pEMAIL; */
  
  /* IF (vAUX &lt;=&gt; NULL) THEN  */
  
      /*check if the pEMAIL parameter exists*/
      IF EXISTS (select id_cliente from tb_cliente where email = pEMAIL) THEN
  
      /*retrieve the ID and assign it to the variable*/
      select id_cliente into vIDCLI from tb_cliente where email = pEMAIL;
  
          /*insert in BD menssage table*/
          INSERT INTO `tb_msg`(`asn`, `msg`, `id_cli`) VALUES ('pASN','pMSG','vIDCLI');
  
      ELSE
          /*insert new cliente*/
          INSERT INTO `tb_cliente`(`nombre`, `tlfn`, `email`) 
                          VALUES ('pNOMBRE','pTLFN','pEMAIL');
  
          /*recovernew IdCli*/
          SET vIDCLI = (select id_cliente from tb_cliente where email = pEMAIL);
  
          /*insert in message table*/
          INSERT INTO `tb_msg`(`asn`, `msg`, `id_cli`) VALUES ('pASN','pMSG',vIDCLI);
      END IF;
  END; //
  
  DELIMITER //
  </code></pre>
  
  <p>MySQL has said:</p>
  
  <blockquote>
    <p>1064 -  Something is wrong in its syntax near 'IF EXISTS (select id_cliente from tb_cliente where email = pEMAIL) THEN' on line 25</p>
  </blockquote>