I'm trying to create a database named 'uppg' and then use that database once it's created. The first statement executes as it should, but nothing happens when I try to use the database with the variable. I have tried multiple variations but I don't know why it's not working.
SET @dbname = 'uppg';
SET @q1 = CONCAT(
'CREATE DATABASE `', @dbname, '`');
PREPARE stmt1 FROM @q1;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
SET @q2 = CONCAT(
'USE ', @dbname,
);
PREPARE stmt2 FROM @q2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;