mysql - How to use String variable value in 'create table' statement? -


this question has answer here:

i have stored procedure in create new tables table_name being variable. though

select table_name;

returns variable value

create table table_name(some_columns);

creates table name table_name , not value.

you need execute prepared statement:

set @sql = concat('create table ', table_name, ' (some_columns);'; prepare stmt @sql; execute stmt; 

Comments

Popular posts from this blog

html - jquery - p element wont show after I hid it -

python - BeautifulSoup: How to get the nearest tag -

php - Return Last Insert ID with PDO -