0
请谁能告诉我为什么这个stored procedure
不工作,我做错了什么。它不断给语法错误。准备语句查询语法错误
puserid and plimit
是过程中传递的参数。
DECLARE uid BIGINT;
DECLARE rangee TINYINT;
SET @uid = puserid;
SET @rangee = plimit * 15;
PREPARE STMT FROM
'IF((SELECT count(type) from notificationrecievers nr where
nr.status=0 and nr.recieverid=?) = 0) THEN
select nr.type,n.senderid,n.postid,u.name,nr.status
from
user u,notifications n,notificationrecievers nr where
nr.recieverid=? and u.userid=n.senderid and
nr.notificationid=n.notid order by n.notid desc
limit 15 OFFSET ?;
ELSE
select nr.type,n.senderid,n.postid,u.name,nr.status
from
user u,notifications n,notificationrecievers nr where
nr.recieverid=? and u.userid=n.senderid and nr.status=0 and
nr.notificationid=n.notid order by n.notid desc;
END IF;';
EXECUTE STMT USING @uid,@uid,@rangee,@uid;
这是我得到的错误。
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF((SELECT count(type) from notificationrecievers nr where nr.status=0 and nr.r' at line 1
我编辑了这个问题。 – Mj1992
你什么时候得到这个错误?同时创建PROCEDURE或执行它?我可以创建这个程序就好了。 – SparKot
我在执行过程时出现此错误。 – Mj1992