ALTER TABLE WITH VALUES FROM SELECT I have a table1 with fluctuating number of columns. (colname1,colname2,colname3...colnamen)

I want to :

ALTER TABLE table2 CHANGE COLUMN `columns` `columns` ENUM('colname1','colname2','colname3' .... '') ...


each time the table1 gets changed in the structure

I know how to get the column names in a table with:

SELECT COLUMN_NAME FROM information_schema.columns WHERE table_schema=


But how can I now get them in a string into the ALTER TABLE ?
@nbk had given what you want - atleast what you made us to understand.

But...

Think of re-designing your whole job. Do not go by your fluctuating number of columns. There are better ways. json is one. Transactional database is what is been used in lot of projects. Those are the right methods to store / retrieve than having variable number of columns.