I have a procedure like below
DROP PROCEDURE IF EXISTS mp_search_result;
CREATE PROCEDURE mp_search_result()
BEGIN
CREATE TEMPORARY TABLE temp_projids(projid int);
SET @strSearchSQL = 'SELECT DISTINCT project_id
FROM tblProjects';
PREPARE stmt FROM @strSearchSQL;
INSERT INTO temp_projids(projid) values ();
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END;
Now I want to insert the project ids returned by the above query into a temporary table.
I am confused with where to write the insert query before execution.
Please note that my requirement is different from query which I posted above.
I am using many if conditions and concatenation for forming @strSearchSQL.
I removed those to prevent the complexity in code.
1 Answer