I want to create a SQL script for MySQL 5.7 that inserts data from a table of a database origin into a table of another target database.
I want to have this source-database defined by a variable.
USE my_target_db;
SET @origin_db='my_origin_db';
SET @origin_table = concat(@origin_db,'.','tablename');
INSERT INTO target_table SELECT * FROM @origin_table;
Variables are used in various example to define column names but I never seen a way to define a table with it.
Is anyone has a trick for this ?