SELECT last_played INTO @lp FROM sr WHERE creator_id = 1 AND playing = 1 LIMIT 1;
SELECT stream_id INTO @sid FROM account_stream WHERE owner = 1 AND enabled = 1 LIMIT 1;
UPDATE sr SET last_played = 1412259166 WHERE creator_id = 1 AND playing = 1 LIMIT 1;
IF @lp != NULL THEN UPDATE streams SET duration = (duration + (1412259166 - @lp)) WHERE id = @sid LIMIT 1; END IF;


我想做的是:@lp返回某项内容时(换句话说,在第一个查询中播放为1时),然后执行最后一个更新流查询。

我在phpmyadmin中看到此错误:

1064-您的SQL语法有误;检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第1行“ IF @lp!= 0 THEN UPDATE streams SET duration =(duration +(1412259166-@lp))W”附近使用

如果以前有条件,我从来没有使用过mysql,所以,有人可以帮我吗?

最佳答案

 UPDATE streams SET duration = (duration + (1412259166 - @lp))
 WHERE @lp IS NOT NULL AND id = @sid

关于mysql - MySQL IF表达式返回错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26163016/

10-11 01:23