Det vil virke, hvis du samler hele forespørgslen. Prøv:
set @db = 'mydb';
set @tble = 'table';
set @query = concat('INSERT INTO tablefoo SELECT * FROM ', @db, '.', @tble);
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
Det vil virke, hvis du samler hele forespørgslen. Prøv:
set @db = 'mydb';
set @tble = 'table';
set @query = concat('INSERT INTO tablefoo SELECT * FROM ', @db, '.', @tble);
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;