when i use the follow statement
SET @cnt =0;
select @cnt:=@cnt+1 as ttt,post.*
from post ;
the result is
+-----+----+-----+-------------+
| ttt | id | cid | name |
+-----+----+-----+-------------+
| 1 | 1 | 1 | post1-1-1 |
| 2 | 2 | 1 | post1-2-2 |
| 3 | 3 | 1 | post1-3-3 |
| 4 | 4 | 1 | post1-4-4 |
| 5 | 5 | 1 | post1-5-5 |
+-----+----+-----+-------------+
but if i use this
SET @cnt =0;
select @cnt:=@cnt+1 as ttt,post.*
from post having ttt = 1;
i get
+-----+----+-----+-------------+
| ttt | id | cid | name |
+-----+----+-----+-------------+
| 2 | 1 | 1 | post1-1-1 |
| 3 | 2 | 1 | post1-2-2 |
| 4 | 3 | 1 | post1-3-3 |
| 5 | 4 | 1 | post1-4-4 |
| 6 | 5 | 1 | post1-5-5 |
+-----+----+-----+-------------+
i think the result may be just include one row which the ttt is 1
just like this
+-----+----+-----+-------------+
| ttt | id | cid | name |
+-----+----+-----+-------------+
| 1 | 1 | 1 | post1-1-1 |
+-----+----+-----+-------------+
i'm puzzled, how mysql work with user-defined variable?
and when the variable will be calculate, after having?
my version of mysql is 5.0.21-community-nt.