Dropping rows based on the previous selection statmnet
To get a dynamically formed SQL statement you need to get it into a user variable, @drop, and then execute this:

SELECT CONCAT('DROP TABLE ',
              GROUP_CONCAT(CONCAT(TABLE_SCHEMA,'.',TABLE_NAME))) INTO @drop
FROM information_schema.TABLES
WHERE  table_schema = 'db' AND
       table_name like 'temp%' AND
       CREATE_TIME &lt; (NOW()-INTERVAL 24 HOUR);
PREPARE dropstmt FROM @drop;
EXECUTE dropstmt;
DEALLOCATE PREPARE dropstmt;


To clean up cached_tbl, delete where there isn't match on the join:

DELETE c FROM cached_tbl c 
LEFT JOIN information_schema.TABLES t ON t.TABLE_NAME = c.table_name
WHERE t.TABLE_NAME IS NULL