My question is related to the answer found in this post by user Consultuning on Oct 22 \'09 at 18:31: mysql query to dynamically convert row data to columns
The closest thing to "for each" is probably MySQL Procedure using Cursor and LOOP.