title: How can I loop through all rows of a table? (MySQL)
body: <p>I have a table A and there is one primary key ID.</p>
  
  <p>Now I want to go through all rows in A.</p>
  
  <p>I found something like 'for each record in A', but this seems to be not how you do it in MySQL.</p>
  
  <p>Thing is for each row I want to take a field and transform it, insert it into another table and then update some of the row's fields. I can put the select part and the insert into one statement, but I don't know how to get the update in there as well. So I want to loop. And for practice I don't want to use anything else than MySQL.</p>
  
  <p><strong>edit</strong></p>
  
  <p>I would appreciate an example.</p>
  
  <p>And a solution which does not need to be put into a procedure.</p>
  
  <p><strong>edit 2</strong></p>
  
  <p>okay think of this scenario:</p>
  
  <p>Table A and B, each with fields ID and VAL.</p>
  
  <p>Now this is the pseudo code for what I want to do:</p>
  
  <pre><code>for(each row in A as rowA)
  {
    insert into B(ID, VAL) values(rowA[ID], rowA[VAL]);
  }
  </code></pre>
  
  <p>basically copying content of A into B using a loop.</p>
  
  <p>(this is just a simplified example, of course you wouldn't use a loop for this.)
  }</p>