mysql - How to use String variable value in 'create table' statement? -
this question has answer here:
- mysql create table dynamically 1 answer
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
Post a Comment