title: Mysql Inner query gives all column names of outer query selected table name
body: <p>I am using MySql 5.6.10 , I want a query which has Outer query "table name" to be used in Inner Query  to get all the columns of the "Table"(of Outer Queries) , </p>
  
  <p>I have two tables in a DB say <strong>test</strong></p>
  
  <p>First Table <strong>tbl_1</strong></p>
  
  <pre><code>CREATE TABLE `tbl_1` (
    `id` int(10) NOT NULL AUTO_INCREMENT,
    `log_id` int(10) DEFAULT NULL,
    `new_loc_id` int(10) DEFAULT NULL,
    `old_loc_id` int(10) DEFAULT NULL,
    `msg` varchar(255) DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>Second Table <strong>tbl_2</strong></p>
  
  <pre><code>CREATE TABLE `tbl_2` (
    `id` int(10) NOT NULL AUTO_INCREMENT,
    `name` varchar(25) DEFAULT NULL,
    `loc_id` int(10) DEFAULT NULL,
    `parent_id` int(10) DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>I have composed something like this:</p>
  
  <pre><code>SELECT CONCAT('|QUERY|Select * from  test.',tbl.table_name,'|\n' ,
  '|COLUMN|',(SELECT GROUP_CONCAT(COLUMN_NAME SEPARATOR ' | ') FROM information_schema.COLUMNS clm
  WHERE table_schema = 'test' 
  AND tbl.table_name = clm.table_name),'|\n'
  ) AS ddl
  INTO OUTFILE '/tmp/test.txt'
  FROM information_schema.TABLES tbl
  WHERE tbl.table_schema = 'test'
  AND tbl.table_type = 'base table';
  </code></pre>
  
  <p>OutPut of the Query is error:</p>
  
  <pre><code>Error Code : 1054
  Unknown column 'tbl.table_name' in 'where clause'
  </code></pre>
  
  <p>What I'm expecting is :</p>
  
  <pre><code>|QUERY|Select * from  test.tbl_1|
  |COLUMN|id | log_id | new_loc_id | old_loc_id | msg | id | name | loc_id | parent_id|
  
  |QUERY|Select * from  test.tbl_2|
  |COLUMN|id | name| loc_id| parent_id|
  </code></pre>