title: execute query result statements
body: <p>I've got a set of tables named results_%, all with the same structure.</p>
  
  <p>I would like to add a index to this tables.</p>
  
  <p>I can get the alter statement for each table as a row of a select query result but I don't know how to execute this statements:</p>
  
  <pre><code>select concat( 'alter table ', test_db.table_name, ' add index `did` (`did`);' ) as statement 
  from information_schema.tables test_db 
  where test_db.table_name like 'results_%';
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>The ouput (which I would like to execute instead of just have it displayed to me):</p>
  
  <pre><code>+---------------------------------------------------------+
  | statement                                               |
  +---------------------------------------------------------+
  | alter table results_Em7777_spa add index `did` (`did`); |
  | alter table results_KaEng_eng add index `did` (`did`);  |
  | alter table results_Ka_spa add index `did` (`did`);     |
  | alter table results_Mc_spa add index `did` (`did`);     |
  | alter table results_Mo_eng add index `did` (`did`);     |
  | alter table results_Pe_eng add index `did` (`did`);     |
  | alter table results_SU_spa add index `did` (`did`);     |
  | alter table results_Ta_spa add index `did` (`did`);     |
  | alter table results_ba_eng add index `did` (`did`);     |
  | alter table results_br_eng add index `did` (`did`);     |
  | alter table results_ca_spa add index `did` (`did`);     |
  | alter table results_ch_spa add index `did` (`did`);     |
  | alter table results_da_spa add index `did` (`did`);     |
  | alter table results_ga_eng add index `did` (`did`);     |
  | alter table results_ge_spa add index `did` (`did`);     |
  | alter table results_gk_eng add index `did` (`did`);     |
  +---------------------------------------------------------+
  16 rows in set (0.00 sec)
  </code></pre>
  
  <p>[EDIT]</p>
  
  <p>I tried:</p>
  
  <pre><code>drop procedure if exists altlike; 
  delimiter // 
  create procedure altlike() 
  begin 
     set group_concat_max_len = 65535; 
     select @altrlk:= concat( 'alter table ', test_db.table_name , ' add index `did` (`did`);' )
     from information_schema.tables test_db
     where test_db.table_name like "results_%"; 
     prepare statement from @altrlk; 
     execute statement; 
  end // 
  delimiter ; 
  call altlike();
  </code></pre>
  
  <p>But still no luck: It only alters the last matched table (results_gk_eng).</p>