Bude to fungovat, pokud spojíte celý dotaz. Zkuste:
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;
Bude to fungovat, pokud spojíte celý dotaz. Zkuste:
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;