title: Using select into local variable and prepared statement in mysql
body: <p>Everytime call this stored procedure i get this error:</p>
  
  <pre><code>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1
  </code></pre>
  
  <p>What seems to be the problem?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>DELIMITER $$
  
  DROP PROCEDURE IF EXISTS `singledb`.`TOUR_TRANSFER`$$
  
  CREATE DEFINER=`root`@`localhost` PROCEDURE `TOUR_TRANSFER`()
  BEGIN
  
  BEGIN -- for rubric table
              DECLARE tblRubric_rubric_id INT;
              SET @qry = concat('SELECT count(*) into ',tblRubric_rubric_id,' FROM zerodb2.tour_template');
              PREPARE statement FROM @qry;
              EXECUTE statement;
  
              SELECT tblRubric_rubric_id;
  END;
  END$$
  
  DELIMITER ;
  </code></pre>