思路:为时间段内的数据进行编序号,然后计算好相隔时间,拿到id作为搜索条件
SELECT * FROM (
SELECT
(@i:=@i+1) as i, id, data_send_time
FROM
jl_pims_machine_time mt,(select @i:=0) as it where mt.company_id = 1001 AND mt.machine_id = 1 order by mt.id desc
) tmp
WHERE
i IN (1,3,5)
思路:为时间段内的数据进行编序号,然后计算好相隔时间,拿到id作为搜索条件
SELECT * FROM (
SELECT
(@i:=@i+1) as i, id, data_send_time
FROM
jl_pims_machine_time mt,(select @i:=0) as it where mt.company_id = 1001 AND mt.machine_id = 1 order by mt.id desc
) tmp
WHERE
i IN (1,3,5)
转载于:https://www.cnblogs.com/phonecom/p/7201197.html