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,872
  • 12
  • 52
  • 91

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,430
  • 2
  • 37
  • 55