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
Post a Comment