このエラーが発生する理由を説明する次の手順can't reopen table
があります。クエリは次のとおりです。
DECLARE rangee INT;
DECLARE uid BIGINT;
SET @rangee = plimitRange * 10;
SET @uid = puserid;
DROP TEMPORARY TABLE IF EXISTS Rangee;
CREATE TEMPORARY TABLE Rangee(max BIGINT,min BIGINT);
PREPARE STMT FROM
'INSERT INTO Rangee
select max(postid),MIN(postid) from
(
select wall.postid from wall,posts where
wall.postid = posts.postid and posts.userid=?
order by wall.postid desc LIMIT 10 OFFSET ?
)m;
';
EXECUTE STMT USING @uid,@rangee;
DEALLOCATE PREPARE STMT;
select comments.comment,comments.postid,user.name,comments.userid
from user,posts,comments where
posts.postID = comments.postid and
comments.postid<=(select max from Rangee) and
comments.postid>=(select min from Rangee) and posts.userid = puserid and
user.userid=comments.userid order by comments.postid desc;
ここでは、値を別のテーブルから一時テーブルに挿入min
しmax id's
て、それらの値を使用して最終クエリでデータを取得できるようにしてい(select max from Rangee)
ます(select min from Rangee)
。どうすれば解決できますか。min と max の値は問題なく返ってきます。