CREATE DEFINER=`root`@`localhost` PROCEDURE `WhileLoopProc`()
BEGIN
DECLARE x INT;
SET x = 1;
loop1: WHILE x <= 213 DO
SET @s = CONCAT('SELECT Units, NAV FROM jbequity.nav WHERE ClientID =', x ,'ORDER BY Date LIMIT 1');
PREPARE stmt FROM @s;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET x = x + 1;
END WHILE loop1 ;
END
答案 0 :(得分:0)
尝试一次删除ORDER BY Date
和LIMIT 1
一个以查看导致错误的部分,然后google那个无法学习如何使用它的部分。
修改强>
我怀疑问题是你错过了ORDER BY