How do I drop tables in a MySQL database based on a name pattern?

SET @db = '27estore_com_2024_07_11__2';
SET @pattern = 'nwdthemes_%';
SET @tt = NULL;
-- 2024-10-08 It allows to handle large strings, which is important when working with many tables.
SET SESSION group_concat_max_len = 999999;
SELECT
	GROUP_CONCAT('`', table_schema, '`.`', table_name, '`') INTO @tt
	FROM information_schema.tables
	WHERE table_schema = @db AND table_name LIKE BINARY @pattern
;
SET @stmt = IF(@tt IS NOT NULL, CONCAT('DROP TABLE ', @tt), 'SELECT ''Nothing to delete.'' AS message;');
PREPARE s FROM @stmt;
EXECUTE s;
DEALLOCATE PREPARE s;