I have a table like idsfortime:
epochtime id
1392951600 0
1392952500 15
1392953400 30
1392954300 45
1392955200 60
There is another table with the following columns :
15916B 5.1815954385269 1392977820
15965A 7.16797368783744 1392977880
16272B 10.6633890639568 1392977865
16707A 37.6028010736386 1392977785
16730A 9.42097617868767 1392977866
The last column in the above table denotes epoch time.
I am trying to find out those speeds (column 2 in above table) which lie between epochtime
of table idsfortime
and below table .
I am using the below query :
select t.speed from idsfortime t1 JOIN staging t where t1.epochtime >= t.time AND t1.epochtime <= t.time;
But, this doesnt work. Please suggest
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `idsfortime` ADD INDEX `idsfortime_idx_epochtime` (`epochtime`);
ALTER TABLE `staging` ADD INDEX `staging_idx_time` (`time`);
SELECT
t.speed
FROM
idsfortime t1
JOIN
staging t
WHERE
t1.epochtime >= t.time
AND t1.epochtime <= t.time