MySQL返回程序选择的结果

时间:2015-03-04 17:34:15

标签: mysql sql

我在MySQL中遇到了一些问题。在我的程序中,我需要显示选定的表。我不知道我该怎么做。我应该使用变量/变量吗?我怎么用呢?

CREATE DEFINER=`user`@`localhost` PROCEDURE `POI_LIST`(IN `VERSION` INT)
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION SELECT  @@ERROR_COUNT;
IF (@p0 in (select APP_VERSION.VERSION from APP_VERSION Where APP_VERSION.ACCESS=1)) then

        SELECT P.ID,P.PROMOTED, C.COMMENT, D.RATING FROM POI as P
LEFT JOIN COMMENT_TO_POI as C
ON P.ID= C.ID_POI
LEFT JOIN (Select D.ID_POI as POIID, AVG(D.Rate) as RATING 
            from COMMENT_TO_POI as D
            Group By D.ID_POI) as D
on P.ID=D.POIID
order by P.PROMOTED DESC;

ELSE
Select 'ACCESS DENY - OLD VERSION',@p0;
end if;
END

0 个答案:

没有答案