mysql 插值,MySQL插值数据

Is there an 'easy way' to grab two rows of data from a table, and add rows with values 'in-between'?

I want to grab a latitude, a longitude and a timestamp from each row. Compare the timestamp to the one from the previous row, and interpolate new rows if the timestamp is bigger than my minimum...grab two rows 1 minute apart and add rows for every 10 seconds...

Is using a stored procedure the best way to go about this? Easiest?

Currently using mySql and PHP...

解决方案

I would just grab the data and do the math in PHP. SQL isn't all that versatile, and you'd be saving yourself a headache.

EDIT: Actually, just for the fun of it, you could make the math easier by left-joining to a calendar table.

First you need a table ints with the values 0-9. Then you can do something like:

SELECT cal.t, lat, lng FROM (

SELECT {start_time} + INTERVAL (t.i*1000 + u.i*100 + v.i*10) SECOND as t

FROM ints as t

JOIN ints as u

JOIN ints as v

WHERE t <= {end_time}

) LEFT JOIN locations ON (cal.t = locations.stamp)

This would return a table with NULL values for lat and lng where there isn't an entry on the 10 second mark, so you could iterate through and do the math for just those. Keep in mind, this only works if you all the datapoints you do have (other than the start and end) land right on a 10-second mark.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值