title: Mysql query using variables to find three consecutive numbers
body: <p>Write a SQL query to find all numbers that appear at least three times consecutively. The table contains id and Num columns. Num column values should be consecutive.</p>
  
  <p>I am using three varialbes: tert, prev and current to store the three consecutive numbers. However, the following code does not give the right output. I want to know why?</p>
  
  <pre><code>SELECT if((@tert := @prev) = (@prev: = @current) = (@current := Num),Num,'') as ConsecutiveNums
  FROM
    Logs,
    (SELECT @current := -10, @prev := -1, @tert = -1) init
  </code></pre>