0

Is there a way to use a sub select statement, which returns a list of column names, to be used in the 'select expression' in an outer mySQL expression?

eg

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

In case your wondering how I get the comma separated list of column names, my sub select statement is somethign like...

SELECT group_concat(COLUMN_NAME) FROM information_schema.`COLUMNS` 
where table_name = 'table2' group by TABLE_NAME
spiderplant0
  • 3,710
  • 11
  • 48
  • 86

1 Answers1

0

You have to solve this using PREPARE and EXECUTE, as explained here: How To have Dynamic SQL in MySQL Stored Procedure

Community
  • 1
  • 1
Erik A. Brandstadmoen
  • 10,159
  • 2
  • 35
  • 54