我的变量@row_number
的值在WHERE
子句中未更改,但在SELECT
子句中更新了
SET @row_number := -1;
SELECT (@row_number:=@row_number+1) as num,location_table.* FROM location_table
WHERE loc_userID = 'SP_EGMA001'
AND (loc_date >= (STR_TO_DATE('05-27-2019 6:00:00', '%m-%d-%Y %H:%i:%s') + INTERVAL (30 * @row_number) minute))
ORDER BY loc_date asc
答案 0 :(得分:0)
尝试此操作-在外部查询中访问@row_number别名num。任何语法错误的借口。
SET @row_number := -1;
select * from (
SELECT (@row_number:=@row_number+1) as num,location_table.* FROM location_table
WHERE loc_userID = 'SP_EGMA001' ) a
WHERE (loc_date >= (STR_TO_DATE('05-27-2019 6:00:00', '%m-%d-%Y %H:%i:%s') + INTERVAL (30 * num) minute))
ORDER BY loc_date asc