How to create temporary table in MySQL
|
Here is the syntax to create temporary table by getting data from another table with in a stored procedure.
SET @TEMPQUERY = ‘CREATE TEMPORARY TABLE TEMP_EMP_TABLE’;
SET @TEMPQUERY = CONCAT (@TEMPQUERY, ‘ AS SELECT EMP_ID, EMP_NAME, EMP_ADDRS, EMP_PHONE FROM EMPLOYEE ‘);
SET @TEMPQUERY = CONCAT (@TEMPQUERY, ‘ WHERE EMP_ID IN (SELECT EMP_ID FROM EMP_COMPANY)’);
PREPARE MYSQLQUERY FROM @TEMPQUERY;
EXECUTE MYSQLQUERY;
|
0 comments:
Post a Comment