Hi All,
I am finding problem in get correct result from query that I have written.
Below is my mysql query to get the levelId,levelRange,16,NextRange from database
"select levelId,levelRange,16 as totalSave,
(
case @i:=(level+1)
when @i then (select levelRange from level where levelId=@i;)
End
) As NextRange
from level where levelRange <= 16 order by levelId desc limit 1"
I have used this query in PHP.
But it always gives me result as 0,0,16,NULL respectively for respective select items.
database table "level" is as follow,
levelId| levelRange
1 | 5
2 | 10
3 | 15
4 | 20
5 | 25
Here, the value "16" decides the next range value. So expected result should be "3,15,16,20"
where "levelId=3,levelRange=15,totalSave=16,NextRange=20".
Is their any way to get this result. I am using @i as to make it dynamic. So that no change will be required from coding side if in future levelId and levelRange changes from database