如何在mysql中为select语句中的多个参数编写存储过程?

时间:2015-11-29 07:15:52

标签: mysql stored-procedures

这是我第一次编写存储过程。这是我的存储过程

CREATE DEFINER=`test`@`%` PROCEDURE `List`(OUT id INT, OUT SCORE INT)
BEGIN
select (Listing.Viewcount * 0.4) + count(Bookmarks.ListingId * 0.6) As Score INTO SCORE, distinct(Listing.ListingId) INTO id
from Listing,Bookmarks
where Listing.ListingId = Bookmarks.ListingId
group by Listing.ListingId
order by Score desc
Limit 10;
END

它在select语句中出现错误,说“语法错误:意外(明显)不同”。我无法弄清楚为什么这是错的? 非常感谢帮助! :) 感谢。

1 个答案:

答案 0 :(得分:0)

CREATE DEFINER=`test`@`%` PROCEDURE `List`(OUT id INT, OUT SCORE INT)
BEGIN
select (Listing.Viewcount * 0.4) + count(Bookmarks.ListingId * 0.6),distinct(Listing.ListingId)
       INTO SCORE, id
from Listing,Bookmarks
where Listing.ListingId = Bookmarks.ListingId
group by Listing.ListingId
order by Score desc
Limit 1;
END