我想在MySQL 5.6中创建函数。这个函数将由计数玩家乘以param。但我不知道怎么做。
我想是这样的,但它没有按预期工作。
DROP FUNCTION IF EXISTS do_it;
DELIMITER $$
CREATE FUNCTION do_it (s INT) RETURNS INT DETERMINISTIC
BEGIN
DECLARE k INT;
SELECT COUNT(id_player) as allPlayers FROM players;
SET k= allPlayers * s;
RETURN k;
END$$
DELIMITER ;
SELECT do_it(2);
答案 0 :(得分:-1)
而是这样做
DECLARE k INT;
declare multiplyvar int;
SELECT COUNT(id_player) into multiplyvar FROM players;
SET k = multiplyvar * s;
RETURN k;