0

I tried this code with parse error at line 2...

BEGIN
  SELECT @count
  SET @count= 1;

  WHILE @count < 20 DO
    SELECT COUNT (*)  from `meteo`.`table 3` where `Temp Out`>20+@count
    SET @count = @count + 1;
  END WHILE;
END

ALso I tried this with the same error result...

BEGIN
  DECLARE @count INT DEFAULT 1;

  WHILE @count > 20 DO
    SELECT COUNT(*)  from `meteo`.`table 3` where `Temp Out`>20+@count
    SET @count = @count + 1;
  END WHILE;
END

What is my fault?

zealous
  • 7,336
  • 4
  • 16
  • 36
liontass
  • 730
  • 9
  • 24
  • Is this code inside a stored procedure? – Nick May 24 '20 at 06:38
  • No i don't have this in a procedure. I run this code as a trtaining example – liontass May 24 '20 at 06:42
  • 2
    You can't use compound statements in MySQL other than in stored procedures, functions, triggers and events. See the [manual](https://dev.mysql.com/doc/refman/8.0/en/begin-end.html) – Nick May 24 '20 at 06:44
  • 1
    You cannot declare a user defined variable see https://stackoverflow.com/questions/11754781/how-to-declare-a-variable-in-mysql. Every statement needs a terminator. ALSO you may be attempting to run sqlserver code in mysql - that won't work the 2 dialects are too different. – P.Salmon May 24 '20 at 07:46

0 Answers0