Answer the question
In order to leave comments, you need to log in
How (and is it possible) to add fields with calculated names to a table in bare MySQL?
Yes, not just with calculated ones, but based on data from other tables.
There is a language table:
id | name |
---|---|
one | Russian |
2 | English |
id | guide |
---|---|
one | Russia |
2 | france |
id | guide | name_1 | name_2 |
---|---|---|---|
one | Russia | ||
2 | france |
Answer the question
In order to leave comments, you need to log in
copist: It's not very clear what exactly should be in the name_1 name_2 columns
0lorin: In the future, country names in languages from the first table.
Try the approach like here forums.mysql.com
(example from the link page)
set @addcoltext = concat('ALTER TABLE nick.mytable ADD COLUMN ',concat('day',dayofmonth(curdate() - interval 1 day)),' INTEGER UNSIGNED;');
prepare addcol from @addcoltext;
execute addcol;
deallocate prepare addcol;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question