title: How do i get column values of my sql table dynamically using stored procedures?
body: <p>I am learning stored procedures. Coming to the problem I have a table where columns are named as Q1,Q2,Q3...,Q10 . I want to retrieve these values dynamically using while loop (or for loop). I tried something but that didn't give me actual output. Please give me some suggestions.</p>
  
  <p><strong>My code is as follows :</strong></p>
  
  <pre><code> delimiter //
      drop procedure if exists exam//
      create procedure exam ()
      begin
      declare a int default 1;
      while a &lt;= 9 do 
      select  concat(Q,a) from feed1 where col = 'XYZ';
      set a= a + 1;
      end while;
      end ;
      //
      delimiter ;
      call exam;
  </code></pre>
  
  <p>When i run this i am getting an error <strong>" Unknown column Q in field list "</strong></p>