If I have the output of a prepared statement; how do I use it as the source of my query?
CALL `myProcedure`;
PREPARE stmnt FROM @allSQL;
EXECUTE stmnt;
DEALLOCATE PREPARE stmnt;
So, I get an output from the EXECUTE stmnt;
(let's call it tmp
) and I would like to run a query along the lines of:
SELECT * FROM (EXECUTE stmnt) AS tmp WHERE this = that;
You could prepare a CREATE TEMPORARY TABLE
statement that contains the result of the query:
SET @createSQL = CONCAT('CREATE TEMPORARY TABLE tmp AS ', @allSQL);
PREPARE stmt FROM @createSQL;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SELECT * FROM tmp WHERE this = that;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.