Is it possible to save the result of a prepared table in mysql?
My use case is:: I create two variables based on certain conditions of the original table, and then get randomized rows based on these criteria. Since I have 10 such tables, I must be the first to join them, and then perform this randomization according to the βgeneralβ criteria for passing / filtering (see also @total below, which is my main criterion, the PER table)
set @total=(select count(*) from tab_1 where predict_var ="4" or predict_var ="2" ) ;
set @sample= ( select @total*(70/30)) ;
PREPARE STMT FROM " SELECT * FROM tab_1 WHERE predict_var = '4' or predict_var = '2' union
(SELECT * FROM tab_1 WHERE predict_var = '0' or predict_var = '1' ORDER BY RAND() limit ? )" ;
EXECUTE STMT USING @sample;
After executing this statement - I want to store these lines for later search, preferably in the form of a table. I would like to do something like this
create table tab_derived_1
select * from
EXECUTE STMT USING @sample;
Tip: +1 for an additional mention of why this does not work with prepared statements.