Logic Value of Assignment Expression
PROPOSED SOLUTION

Using the IF() function to check for consecutive num values

SET @x = 0;
SET @n = 0;
SELECT num,consecutive FROM
(SELECT
    id,num,
    (@x:=IF(num=@n,@x+1,1)) consecutive,
    (@n:=num) inc
FROM logs) A
WHERE consecutive &gt;= 3;


YOUR SAMPLE DATA

DROP DATABASE IF EXISTS tonychen;
CREATE DATABASE tonychen;
USE tonychen
CREATE TABLE logs
(
  id INT NOT NULL AUTO_INCREMENT,
  num INT NOT NULL,
  PRIMARY KEY (id)
);
INSERT INTO logs (num) VALUES (1),(1),(1),(2),(1),(2),(2);
SELECT * FROM logs;


YOUR SAMPLE DATA LOADED

mysql&gt; DROP DATABASE IF EXISTS tonychen;
Query OK, 1 row affected (0.25 sec)

mysql&gt; CREATE DATABASE tonychen;
Query OK, 1 row affected (0.00 sec)

mysql&gt; USE tonychen
Database changed
mysql&gt; CREATE TABLE logs
    -&gt; (
    -&gt;   id INT NOT NULL AUTO_INCREMENT,
    -&gt;   num INT NOT NULL,
    -&gt;   PRIMARY KEY (id)
    -&gt; );
Query OK, 0 rows affected (0.31 sec)

mysql&gt; INSERT INTO logs (num) VALUES (1),(1),(1),(2),(1),(2),(2);
Query OK, 7 rows affected (0.05 sec)
Records: 7  Duplicates: 0  Warnings: 0

mysql&gt; SELECT * FROM logs;
+----+-----+
| id | num |
+----+-----+
|  1 |   1 |
|  2 |   1 |
|  3 |   1 |
|  4 |   2 |
|  5 |   1 |
|  6 |   2 |
|  7 |   2 |
+----+-----+
7 rows in set (0.00 sec)

mysql&gt;


PROPOSED SOLUTION EXECUTED

mysql&gt; SET @x = 0;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SET @n = 0;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SELECT num,consecutive FROM
    -&gt; (SELECT
    -&gt;     id,num,
    -&gt;     (@x:=IF(num=@n,@x+1,1)) consecutive,
    -&gt;     (@n:=num) inc
    -&gt; FROM logs) A
    -&gt; WHERE consecutive &gt;= 3;
+-----+-------------+
| num | consecutive |
+-----+-------------+
|   1 |           3 |
+-----+-------------+
1 row in set (0.00 sec)

mysql&gt;


GIVE IT A TRY !!!