在phpmyadmin中执行mysql存储过程文件的问题

时间:2016-06-03 11:48:10

标签: mysql database phpmyadmin

我在phpmyadmin中运行脚本时在mySQL中有一个存储过程,它会出现语法错误。当手动创建时,执行.Anyhelp将不胜感激

enter image description here

当我运行SQL查询时,当我手动创建phpmyadmin存储过程函数时,它会显示错误

CREATE PROCEDURE `sp_ConsolidatedFollowFeedUserList`(
 _uid INT,
 _startTime INT,
 _endTime INT,
 _activityType VARCHAR(150),
 `_follow_to` INT,
 `_offset` INT,
 `_limit` INT
)
BEGIN

 SELECT
  feed.id `feed_id`,
  activity.id ` activity_id`,
  activity.uid AS `uid`,
  activity.source_id AS follow_to,
  activity.activity_type,
  activity.source_id,
  activity.parent_id,
  activity.parent_type,
  activity.post_id
 FROM
  `user_feed` feed
 JOIN user_activity activity ON feed.activity_id = activity.id
 WHERE
  feed.uid = _uid
  AND feed.`status` = 'ACTIVE'
  AND activity.`status` = 'ACTIVE'
  AND activity.activity_type IN(_activityType)
  AND activity.created BETWEEN startTime AND endTime
  AND activity.source_id = _follow_to
 ORDER BY
  activity.created DESC
 LIMIT 
  offset, limit;

END

1 个答案:

答案 0 :(得分:0)

如果您的存储过程在文件中,那么您不需要``来保护列字段。那么您的参数名称必须完全匹配offset_offset不匹配。

CREATE PROCEDURE `sp_ConsolidatedFollowFeedUserList`(
     _uid INT,
     _startTime INT,
     _endTime INT,
     _activityType VARCHAR(150),
     _follow_to INT,
     _offset INT,
     _limit INT)

BEGIN

 SELECT
  feed.id AS feed_id,
  activity.id AS activity_id,
  activity.uid AS uid,
  activity.source_id AS follow_to,
  activity.activity_type,
  activity.source_id,
  activity.parent_id,
  activity.parent_type,
  activity.post_id

 FROM
  user_feed AS feed
  JOIN user_activity activity ON feed.activity_id = activity.id
 WHERE
  feed.uid = _uid
  AND feed.status = 'ACTIVE'
  AND activity.status = 'ACTIVE'
  AND activity.activity_type IN (_activityType)
  AND activity.created BETWEEN _startTime AND _endTime
  AND activity.source_id = _follow_to
 ORDER BY activity.created DESC
 LIMIT _offset, _limit;

END