次のクエリがあります。
select wall.postid from wall,posts where
wall.postid = posts.postid and posts.userid=puserid
order by wall.postid desc LIMIT 4 OFFSET 0;
次の方法で結果を返します。
wall.postid
-----------------
52
51
50
49
ここで、次のクエリで使用できるように、最大値、つまり 52 と最小値、つまり 49 を変数に保存したいと考えています。次のクエリを使用してそうしています。
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;
私は持っていますが、これらの変数は、この結果セットではなく、列の最大 ID と最小 ID を保存します。つまり、列の最小値である最大 = 52 と最小 = 41 を返します。最小 = 49 が必要です。