Padding MySQL queries I'm trying to retrieve logs of our plant where a certain event has occurred. 

At the moment, I can query the actual event by using an alarm_code field. However, I'd also like to include about an hour's worth of data before and after the alarm event.

How would I go about doing this?

The timestamp field is also the primary key, if that helps.

Thanks,
SELECT (My_Field_List) 
FROM My_Table 
WHERE My_Timestamp BETWEEN TIMESTAMPADD(HOUR, -1, Alarm_Time) 
  AND TIMESTAMPADD(HOUR, 1, Alarm_Time); 


Details available in the ever useful documentation here.

Example:

mysql&gt; CREATE TABLE Sample(My_Timestamp TIMESTAMP);
Query OK, 0 rows affected (0.71 sec)

mysql&gt; SELECT * FROM Sample;
+---------------------+
| My_Timestamp        |
+---------------------+
| 1999-01-01 00:00:01 |
| 2010-01-01 00:00:01 |
+---------------------+
2 rows in set (0.00 sec)


mysql&gt; SELECT My_Timestamp FROM Sample WHERE My_Timestamp BETWEEN TIMESTAMPADD(HOUR, -1, '1999-01-01 00:00:01') AND TIMESTAMPADD(HOUR, 1, '1999-01-01 00:00:01');
+---------------------+
| My_Timestamp        |
+---------------------+
| 1999-01-01 00:00:01 |
+---------------------+
1 row in set (0.00 sec)