我正在尝试使用phpMyAdmin创建一个 MySQL 函数并收到此错误。
#1415 - 不允许从函数返回结果集
功能代码如下:
DELIMITER $$
CREATE FUNCTION get_binary_count(a INT, c INT)
RETURNS INT
DETERMINISTIC
BEGIN
DECLARE c1, c2 INT;
SET c1 = 0;
SET c2 = 0;
SELECT left_id AS c1 FROM mlm_user_mst WHERE parent_id = a AND left_id > 0;
SELECT right_id AS c2 FROM mlm_user_mst WHERE parent_id = a AND right_id > 0;
IF (c1 > 0 AND c2 > 0) THEN
SET c = c + 1;
SET c = c + get_binary_count(c1, 0);
SET c = c + get_binary_count(c2, 0);
END IF;
RETURN c;
END$$
DELIMITER ;
有什么建议么?
提前致谢。