Is there any way in MySQL to put the name of the database into a variable? For example, when I have a database called 'db1', can I do something like this:
set @db= 'db1';
select * from @db.mytable;
EDIT: There is another example of what I want to do:
set @dbfrom= 'db1';
set @dbto= 'db2';
insert into @dbto.mytable (col1,col2,col3) select col2,col1,col3 from @dbfrom.mytable;