在我的查询中,我想使用分钟计数器。
SET @totalcount=SEC_TO_TIME(0);
select
@totalcount := @totalcount + getTimePeriodBetweenTwoStops(r1.time1, r1.time2)
-- , getTimePeriodBetweenTwoStops(r1.time1, r1.time2)
,r1.*
from route r1
函数 getTimePeriodBetweenTwoStops 实际上返回两点之间的时间。 但我不知道为什么我不能通过返回值增加计数器(@totalcount)。 @totalcount 每次都为 NULL :'(
谢谢!
最佳答案
您尝试过使用addtime()
吗?
SET @totalcount=SEC_TO_TIME(0);
select
@totalcount := addtime(@totalcount, getTimePeriodBetweenTwoStops(r1.time1, r1.time2))
-- , getTimePeriodBetweenTwoStops(r1.time1, r1.time2)
,r1.*
from route r1
关于mysql - 如何使用var作为计数器作为累加值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18317072/