Mysql循环错误

时间:2011-11-02 18:25:01

标签: mysql loops

我正在编写我的第一个mysql循环,以便对表进行重复数据删除。语法似乎并不复杂,但我似乎无法得到它。我收到了错误......

You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the
right syntax to use near 'loop set @id := null' at line 1

这是循环...

loop

  set @id := null;

  select @id := id from race
  group by id having count(1) > 1
  limit 1;

  if @id is null then
    leave;
  end if;

  delete from race where id = @id limit 1;

 end loop;

提前致谢!

0 个答案:

没有答案