我创建了一个程序来从表中找出丢失的 id,但它没有检索到任何结果,下面是程序
DELIMITER ||
DROP PROCEDURE IF EXISTS proc_rpt ||
CREATE PROCEDURE proc_rpt()
BEGIN
SET @minID = (SELECT MIN(`id`) FROM `tbl_film` WHERE `user_id`=13);
SET @maxID = (SELECT MAX(`id`) FROM `tbl_film` WHERE `user_id`=13);
REPEAT
SET @tableID = (SELECT `id` FROM `tbl_film` WHERE `id` = @minID);
IF (@tableID IS NULL) THEN
INSERT INTO temp_missing(`missing_id`) VALUES (@tableID);
END IF;
SET @minID = @minID + 1;
UNTIL (@minID <= @maxID)
END REPEAT; // earlier I was missing this line which was giving error in Procedure.
END; ||
然后我在上面打电话
CALL rpt_proc();
film_id
但是在 tbl_missing 上没有结果,而我可以看到in有很多缺失值tbl_film
。有人会告诉我我做错了什么吗?