I’ve the following query:
select wall.postid from wall,posts where
wall.postid = posts.postid and posts.userid=puserid
order by wall.postid desc LIMIT 4 OFFSET 0;
It returns results in the following manner.
wall.postid
-----------------
52
51
50
49
Now I want to save the max value i.e 52 and min value i.e 49 in a variable so that I can use it in my next query.I am using the following query to do so.
select @upper:=max(wall.postid),@lower:=min(wall.postid) from wall,posts where
wall.postid = posts.postid and posts.userid=puserid
order by wall.postid desc LIMIT 4 OFFSET 0;
I’ve but these variables save the max and min ids of the column not this result set.i.e
it returns me max = 52 and min = 41 which is the minimum value of the column.I need min = 49.
1 Answer