title: mysql dynamic query in stored procedure
body: <p>i am creating a dynamic query in stored procedure. my stored procedure is as follows:</p>
  
  <pre><code>CREATE PROCEDURE `test1`(IN tab_name VARCHAR(40),IN w_team VARCHAR(40))
  BEGIN
  SET @t1 =CONCAT("SELECT * FROM ",tab_name," where team=",w_team);
   PREPARE stmt3 FROM @t1;
   EXECUTE stmt3;
   DEALLOCATE PREPARE stmt3;
  END
  </code></pre>
  
  <p>when i try to run it with the following call:</p>
  
  <pre><code>call test1 ('Test','SPA');
  </code></pre>
  
  <p>i get the following error message:</p>
  
  <blockquote>
    <p>Error Code: 1054. Unknown column 'SPA' in 'where clause'</p>
  </blockquote>
  
  <p>i tested without where condition and it works fine, but with the where condition its not working, i tried using @ with the variable name but it still does not work.</p>
  
  <p>Thanks for your help.</p>