SET @total_people = (SELECT COUNT(*) FROM tbl_members);
SET @point_available = (SELECT free_bonus from tbl_bonus);
SET @must_use = @total_people * 15;
IF @point_available > @must_use THEN
SET @bonuses = @money_available - @must_use ;
UPDATE tbl_member SET points = points + 15 WHERE 1;
ELSE
SET @bonuses = @points_available / 15;
UPDATE tbl_member SET points = points + 15 LIMIT @bonuses;
END IF;
SELECT @bonuses
:(它不起作用:( .....整个if声明:'(
抱歉XD ....新手在这里......我试图用英语XD制作...而且很难解释hahah btw ...我试图让存储过程即时通讯有问题if语句...我想设置一个处理总成员的变量..和我得到的总分... free_points =总成员* 15;如果总积分大于自由积分,则更新tbl_member积分=积分+15所有其他积分中的一些将获得免费积分...限制总积分/ 15;抱歉英文不好XD
错误:
#1064 - 您的SQL语法出错;检查与您的MySQL服务器版本对应的手册,以便在'IF point_available>附近使用正确的语法。 must_use THEN
答案 0 :(得分:1)
更改此内容:
SET @point_available =(从tbl_bonus中选择COUNT(free_bonus));
答案 1 :(得分:0)
-_-
大家......我找到了解决方案......PREPARE STMT FROM
"UPDATE tbl_member SET points = points + 15 LIMIT ? ";
SET @1st = (SELECT COUNT(*) FROM tbl_member);
SET @2nd = (SELECT free_bonus FROM tbl_bonus);
SET @3rd = @1st * 15;
SET @4th = @2nd / 15;
SET @5th = (SELECT IF(@3rd > @2nd,@4th,@1st));
EXECUTE STMT USING @5TH;