title: select tables from another table name list (SQL tree merge)
body: <p>In my SQL server, I have a "table_list" that record necessary "sub_tables" like this:</p>
  
  <pre><code>================
  needed_sub_table
  ----------------
  sub_table_1
  sub_table_2             &lt;= table_list_1
  sub_table_3               
  =================
  
  ================
  needed_sub_table
  ----------------
  sub_table_2
  sub_table_6             &lt;= table_list_2
  sub_table_9               
  =================
  </code></pre>
  
  <p>and in sub_tables, they have exactly same columns with different data :</p>
  
  <pre><code>========================
  ID  |  name |  parentID
  ------------------------
  1   |  asv  |    0
  2   |  asdf |    1             &lt;= sub_table_1
  3   |  ggre |    2
  ========================
  
  ========================
  ID  |  name |  parentID
  ------------------------
  4   |  uyer |    3
  5   |  dfgh |    4             &lt;= sub_table_2
  6   |  dhgr |    5
  ========================
  </code></pre>
  
  <p>What I'm trying to do is : merge "sub_tables" that are listed in "table_list"</p>
  
  <p>And I tried :</p>
  
  <pre><code>SELECT * FROM (SELECT needed_sub_list FROM table_list)
  </code></pre>
  
  <p>but it doesn't work.</p>
  
  <p>What I hope to see is :</p>
  
  <pre><code>========================
  ID  |  name |  parentID
  ------------------------
  1   |  asv  |    0
  2   |  asdf |    1             
  3   |  ggre |    2
  4   |  uyer |    3
  5   |  dfgh |    4             &lt;= result of table_list_1 
  6   |  dhgr |    5                (and so for table_list_2....etc.)
  ========================
  </code></pre>
  
  <p>and since my project might need different combinations of sub_tables,
  I must save those combinations in other tables.
  This means I can't just merge sub_tables directly because I can only know what sub_tables are needed according to table_lists.
  Can anyone please help me with this?
  Thanks in advance.</p>