How to: MySQL Get Database Name and Use in Another Query
The following SQL query get the database name and use the name to run another query.
SET @dbname = DATABASE();
ALTER DATABASE @dbname CHARACTER SET utf8 COLLATE utf8_unicode_ci;
References
- https://stackoverflow.com/questions/8096550/mysql-determine-which-database-is-selected
- https://stackoverflow.com/questions/6115612/how-to-convert-an-entire-mysql-database-characterset-and-collation-to-utf-8
- https://stackoverflow.com/questions/49735318/mysql-how-to-find-current-database-assign-it-into-a-string-variable
- https://dev.mysql.com/doc/refman/5.7/en/set-variable.html