title: MySQL dynamic SQL table name and result
body: <p>i'm having a lot of troubles with my sql dinamic code:</p>
  
  <pre><code>DELIMITER $$
  
  CREATE DEFINER=`remotecontroller`@`%` PROCEDURE `check_pwd`(IN pwd VARCHAR(20), 
  IN user VARCHAR(20), IN tab VARCHAR(30), IN pwd_f varchar(30), IN id_f varchar(30), 
  OUT result Bit(1))
      READS SQL DATA
  BEGIN
   set @u_pwd= null;
   set @txt= concat("select pwd_f from ",tab," where id_f = upper(user) into @u_pwd");
   prepare exec from @txt;
   execute exec;
  -- IN previous version the table and column names was preselected: select pwd_f from clinic.np where id_f like upper(user) into u_pwd;
  
       If Password(pwd) =  @u_pwd then set result= 1;
       else set result= 0;
       end if;
  END
  </code></pre>
  
  <p>The goal of code is check one password with other one in table and return bool. Is for test project, i know that i need to change the password plugin, but i'll do in the final project</p>
  
  <p>When i execute the code throws one error 1064, sql syntax error. Can anybody help me? I try a lot of things, thanks everybody!</p>
  
  <p>EDIT - Now, with the same code throws error 1054: unknown column pwd_f in field_list;</p>