I have a history table with a DATETIME column. Is it not possible to assign a variable within a DATEDIFF function? The following statement:
SET @LASTDATETIME='2000-01-01 00:00:00';
SELECT DATETIME, @LASTDATETIME, TIMEDIFF(DATETIME, @LASTDATETIME:=DATETIME) AS CALC, @LASTDATETIME FROM HISTORY
results in this result:
|DATETIME |@LASTDATETIME | CALC | @LASTDATETIME
-------------------------------------------------------------------
2013-01-28 12:11:41 |2000-01-01 00:00:00 |00:00:00 |[BLOB - 19 B]
2013-01-28 12:11:44 |2013-01-28 12:11:41 |00:00:00 |[BLOB - 19 B]
I don't understand why it seems the assignment sort of worked as DATETIME is carried forward to the next record, but the CALC field failed, and after the assignment the value of @LASTDATETIME is a BLOB? Why doesn't this work as I'm expecting?
Thanks for the help.