2011-08-18 121 views
0

有沒有辦法使用sub select語句,該語句返回列名稱列表,以便在外部mySQL表達式的「select expression」中使用?select子句中嵌套的MySQL select語句

select (
    sub select that returns a comma separated list of column names 
) 
from table1; 

如果你想知道我怎麼得到的列名的逗號分隔的列表,我的子select語句是somethign像...

SELECT group_concat(COLUMN_NAME) FROM information_schema.`COLUMNS` 
where table_name = 'table2' group by TABLE_NAME 

回答