title: mysql prepared statement unable to execute. Getting error 1064
body: <pre><code>DELIMITER $$
  
  DROP PROCEDURE IF EXISTS TOUR_TRANSFER $$
  
  CREATE PROCEDURE TOUR_TRANSFER(in_search CHAR(80),tbl CHAR(80),clmn CHAR(80))
  BEGIN
  DECLARE selstmt,sel_cmd VARCHAR(100);
  BEGIN -- for rubric table
          SET selstmt=concat('SELECT ',clmn,' INTO @tbl_data FROM ',tbl,' WHERE ',clmn, ' REGEXP "', in_search,'"');
          select selstmt;
          PREPARE sel_cmd FROM @selstmt;
          EXECUTE sel_cmd;
          select @tbl_data;
          DEALLOCATE PREPARE sel_cmd;
  END;
  END$$
  DELIMITER ;
  </code></pre>
  
  <p>I am getting an error (1064) in the prepare statement whereas I am able to execute it manually.</p>