title: Alter table using sub select
body: <p>I have two tables.  one which is a field info table and the other is a field data table.</p>
  
  <p>by default all field data table columns are set to text fields of some sort (varchar, text, etc)</p>
  
  <p>what i would like to do is this.  Instead of creating the manual ALTER TABLE query:</p>
  
  <pre><code>ALTER TABLE `field_data` 
  CHANGE COLUMN `field_id_2` `field_id_2` decimal NOT NULL, 
  CHANGE COLUMN `field_id_3` `field_id_3` decimal NOT NULL,
  CHANGE COLUMN `field_id_22` `field_id_22` decimal NOT NULL,
  CHANGE COLUMN `field_id_23` `field_id_23` decimal NOT NULL,
  CHANGE COLUMN `field_id_25` `field_id_25` decimal NOT NULL,
  CHANGE COLUMN `field_id_27` `field_id_27` decimal NOT NULL,
  CHANGE COLUMN `field_id_30` `field_id_30` decimal NOT NULL,
  CHANGE COLUMN `field_id_66` `field_id_66` decimal NOT NULL,
  CHANGE COLUMN `field_id_72` `field_id_72` decimal NOT NULL;
  </code></pre>
  
  <p>I would like to write a dynamic ALTER TABLE query based on the field_info table, right now I get those field IDs by doing this query: </p>
  
  <pre><code>SELECT field_id FROM `field_info` WHERE `field_type` = 'a_decimal_field'
  </code></pre>
  
  <p>which returns the values: 2, 3, 22, 23, etc.</p>
  
  <p>So I would need a query (if possible) that alters the table based on the sub select concatenating field_id_ to the result of each sub select and changes the type of that column to decimal.</p>
  
  <p>I know I can do this in php by constructing the query, but I am specifically looking for a pure mysql solution if possible.</p>