以特定间隔将数据从数据库检索到文件中

In database, I have stored data in one second interval, but I want to retrieve the stored data into a file in some particular interval entered by the user.

The data is as below:

TIMESTAMP   VALUES
1436846660  10
1436846661  10
1436846662  10
1436846663  10
1436846664  10

For user entered interval 2, expected result is :

TIMESTAMP   VALUES
1436846660  10
1436846662  10
1436846664  10

I am using the following command to get the data from starttime to stoptime

SELECT
    `VALUES`
INTO
    OUTFILE 'FILEPATH'
    FIELDS TERMINATED BY ''
    LINES TERMINATED BY '
'
FROM
    TABLENAME
WHERE
        TABLENAME.TIMESTAMP >=starttime
    AND TABLENAME.TIMESTAMP <=stoptime;

So, how should I modify this code to include only those data between starttime and stoptime with the particular interval. Please provide me a solution.

This code worked for me . Interval : 2

SELECT
    `value`
--  ,`timestamp`
    INTO outfile 'test.csv'
    FIELDS TERMINATED BY ''
    LINES TERMINATED BY '
'
FROM
    `timestamp_table`
WHERE
        `timestamp` >= 1436846660
    AND `timestamp` <= 1436846670
    AND MOD( `timestamp` ,2) = 0

In the last line , change 2 to whatever interval you would need .

The query selects after the half hour

select
     *
    ,ROUND( TIMESTAMPDIFF( MINUTE ,'2013-07-12' ,Insert_time ) / 48 ) AS 'interval'
FROM
    TABLENAME