0

我有一个如下的存储过程。

在这里,我创建了一个名为tempDesTable的临时表并从数据库中放入数据。现在我必须从另一个选择查询中放入额外的数据。但它显示Error Code : 1327 Undeclared variable: tempDesTable

BEGIN

    CREATE TEMPORARY TABLE tempDesTable AS (SELECT ID, FirstName, LastName FROM t_users WHERE `DesignationID` = p_DesignationID AND BranchID = 0);      

    SELECT ID, FirstName, LastName INTO `tempDesTable` FROM t_users WHERE `DesignationID` = p_DesignationID AND BranchID = p_BranchID;

END$$
4

1 回答 1

3

您需要使用 insert ... select 而不是 select ... into

INSERT INTO tempDesTable SELECT ID, FirstName, LastName FROM t_users 
WHERE `DesignationID` = p_DesignationID AND BranchID = p_BranchID;
于 2013-07-12T06:25:12.300 回答