Can anyone set my MySQL syntax straight please? I am trying to set a user variable called "seconds" to equal the output of the query shown below (and it does work by it's self), but I am constantly geting "You have an error in your SQL syntax" errors.
SET @seconds=AVG(t2.epoch-t1.epoch)
FROM tmp_4045_metrics AS t1, tmp_4045_metrics AS t2
WHERE t1.seq+1 = t2.seq
I have tried SELECT AVG...., (SELECT AVG...), and quite a few others, but always the same error warning that my syntax is incorrect and never any clues to where it's incorrect.
Can anyone point me in the right direction?
Thanks, Rich