mysql 5.1存储过程限制变量

时间:2022-10-07 16:38:31

I have problem executing this proc in my hosted mysql v-5.1. I cant find the problem or error. please help me out.

我在托管的mysql v-5.1中执行此proc时遇到问题。我找不到问题或错误。请帮帮我。

DROP PROCEDURE IF EXISTS `fetchTimeLine`;;    
CREATE PROCEDURE `fetchTimeLine`(IN `delim` int(10))    
BEGIN    
PREPARE STMT FROM     
" SELECT event_id as event,date,schedule,venue,members,descr,about,    
(SELECT src FROM photo WHERE event_id=event LIMIT 0,1) as photo1,    
(SELECT src FROM photo WHERE event_id=event LIMIT 1,1) as photo2,    
(SELECT src FROM photo WHERE event_id=event LIMIT 2,1) as photo3,    
(SELECT scr_shoot FROM videos WHERE event_id=event LIMIT 0,1) as video1,    
(SELECT scr_shoot FROM videos WHERE event_id=event LIMIT 1,1) as video2,    
(SELECT scr_shoot FROM videos WHERE event_id=event LIMIT 2,1) as video3,    
(SELECT src FROM videos WHERE event_id=event LIMIT 0,1) as vsrc1    
FROM activities    
ORDER BY date desc LIMIT ?,?; ";     

SET @START = delim;    
SET @LIMIT = 2;    
EXECUTE STMT USING @START, @LIMIT;    
DEALLOCATE PREPARE STMT;    

END;;    

error I get:

错误我得到:

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 '' at line 4

1064 - 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第4行的''附近使用正确的语法

1 个解决方案

#1


0  

In MySQL, date is a reserved word, and
you have it in your SELECT clause. Try

在MySQL中,date是一个保留字,你可以在SELECT子句中使用它。尝试

`date` 

instead.

Apply the same change in your ORDER BY clause.

在ORDER BY子句中应用相同的更改。

#1


0  

In MySQL, date is a reserved word, and
you have it in your SELECT clause. Try

在MySQL中,date是一个保留字,你可以在SELECT子句中使用它。尝试

`date` 

instead.

Apply the same change in your ORDER BY clause.

在ORDER BY子句中应用相同的更改。