Direct stick picture
Stored procedure is as follows, a stored procedure to select * out of things to group by operation, mysql 5.7 is not supported by default, need group by field, must select the field to view the official mysql manual, they just won the above a few set command can cancel the limit, no really, for two days, a great god teach
DELIMITER $$
USE ` qp_game_loggers ` $$
DROP PROCEDURE IF the EXISTS ` MB_GR_GetBoxResult ` $$
CREATE PROCEDURE ` MB_GR_GetBoxResult ` (IN iKindId INT (11), IN iUserId INT (11))
LABEL_PROC:
The BEGIN
IF iKindId=0 THEN
SELECT *, SUM (Score) AS TotalScore, MAX (curgame) AS RoundCount FROM gamebox_game_result WHERE boxid IN
(SELECT boxid FROM gamebox_game_result WHERE userid=iUserId
AND CollectTime & gt;=NOW () - the INTERVAL is 3600 * 24 * 5 SECOND
The ORDER BY CollectTime DESC) GROUP BY userid, boxid ORDER BY CollectTime DESC;
The ELSE
SELECT *, SUM (Score) AS TotalScore, MAX (curgame) AS RoundCount FROM gamebox_game_result WHERE boxid IN
(SELECT boxid FROM gamebox_game_result WHERE userid=iUserId
AND kindid=iKindId AND CollectTime & gt;=NOW () - the INTERVAL is 3600 * 24 * 5 SECOND
The ORDER BY CollectTime DESC) GROUP BY userid, boxid ORDER BY CollectTime DESC;
END IF;
END LABEL_PROC $$
DELIMITER ;
CodePudding user response:
The default value of empty includes group that optionCodePudding user response: