SELECT COUNT(*) INTO @count FROM `tableName` WHERE `id` = OLD.id;
WHILE @count > -1 DO
SET @count = @count - 1;
/* loop logic in here */
END WHILE;
I have this SQL but when I run it I get an error (SQL Syntax) that MySQL says is near the WHILE @count > -1 DO SET @count = @count - 1;. I've tried wrapping the while in a BEGIN ... END; block but that doesn't affect it at all.
Due to MySQL's brilliantly vague errors I can't work out what I've done wrong.
I'm sure it's very simple but it's late and I can't spot it for the life of me.
tableinstead of an int? I think you want to useselect @count=count(*) from tableName...