Reputation: 4191
Tried this but it doesn't work:
set @thisvar = '2016-05-27';
Alter table temp_table add COLUMN CONCAT('`',@thisvar,'`') VARCHAR(255);
Hope someone knows about this..
Thanks in advance
Upvotes: 1
Views: 46
Reputation: 108676
Is it possible To add column in a table with variable value in mysql?
No, not directly. Data Definition Language (DDL) statements do not allow variable substitution.
You can write a program that will create your DDL statements if you must do this. There are many ways to write such a program, which you can read about.
If you're considering a column in a table for a particular day's information, you probably should read about database normalization. It looks like you are thinking of doing something that will make your tables and software extraordinarily difficult to maintain.
Upvotes: 1