temp tables - MySQL: Syntax error, unexpected '@', expecting ':' -



temp tables - MySQL: Syntax error, unexpected '@', expecting ':' -

i want create temp table dynamically. passing column name parameter stored procedure.

example:

delimiter $$ create procedure sptemp(in nm varchar(50)) begin set @q = concat('create temporary table temptable  // error occuring here @q select distinct ', nm ,' col from table1'); prepare d from @q; execute d; deallocate prepare d; end$$ delimiter ;

error: syntax error, unexpected '@', expecting ':'

set @q = concat('create temporary table if not exists temptable (index(col)) engine=myisam (select distinct ', nm ,' col table1)');

as bonus - index of col column.

mysql temp-tables dynamicquery

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -