title: How to use while loop in mysql (MariaDB)
body: <p>I am trying to use while loop in my stored procedure, but it doesn't want to accept the syntax.
  I am using HeidiSQL as a Studio, database is MySQL MariaDB.</p>
  
  <pre><code>BEGIN
  CREATE TEMPORARY TABLE taskTemp
  SELECT jc.Id as JID
  FROM jobs as j 
  left join jobcards     as jc   on j.JobcardId = jc.Id
  left join tasks        as t    on j.Id = t.JobId
  left join assignments  as a    ON t.Id = a.TaskId
  WHERE a.PerformerId = currentUserId
  group by jc.Id;
  
  SELECT GROUP_CONCAT(JID  SEPARATOR ',') AS result
  INTO @test
  FROM taskTemp;
  
  CREATE TEMPORARY TABLE UserTasks
  Select j.Id ,j.JobcardId as JcID, t.Id as TaskID ,js.Name as TaskStatus
  from jobs                        as j 
  left join tasks             as t on j.Id = t.JobId
       Join assignments       as a on t.Id = a.TaskId and a.PerformerId = currentUserId
  left Join jobstatuses       as js on t.StatusId = js.Id
  WHERE FIND_IN_SET(j.JobcardId, @test);
  
  alter table UserTasks add UserStatus longtext;
  
  SET @n=0;
  SET @i=0;
  
  SELECT COUNT(*) FROM UserTasks INTO @n;
  
  WHILE (@n&gt;0) DO
  SET @n=@n-1;
  END WHILE;
  
  
  drop temporary table taskTemp;
  drop temporary table UserTasks;
  END
  </code></pre>
  
  <p>Above you can see my whole stored procedure, so the problem is coming at this row:</p>
  
  <pre><code>WHILE (@n&gt;0) DO
  SET @n=@n-1;
  END WHILE;*
  </code></pre>
  
  <p>*</p>
  
  <p>I have tried without brackets also @n>0, but also without success</p>