我正在尝试使用 Heidisql 使用以下语法在 mysql 中使用简单循环。
BEGIN
loop_label: LOOP
IF @number_title > @max THEN
**LEAVE loop_label;**
END IF;
select @number_title as number_distinct_title,count(*) as total from (
select count(distinct ctitle), customer_id
FROM table
GROUP BY customer_id
HAVING count(distinct ctitle)=@number_title
ORDER BY customer_id) as total ;
SET @number_title = @number_title + 1;
END LOOP
END
我在LEAVE loop_label处收到语法错误;
有人可以帮忙吗?
谢谢