Reputation: 5760
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;
What I am trying to do: when @lp returns something (in other words, when playing is 1 in the first query), then execute the last update streams query.
I get this error in phpmyadmin tho:
I've never worked with mysql if conditions before, so, can anyone please help me?
Upvotes: 0
Views: 68
Reputation: 7722
UPDATE streams SET duration = (duration + (1412259166 - @lp))
WHERE @lp IS NOT NULL AND id = @sid
Upvotes: 1