For example, given 1339372800, which is Mon, 11 Jun 2012 00:00:00 GMT, I would like to get the next X hours including 1339372800. So for the next 3 hours, the result would be
+------------+ | hours | +------------+ | 1339372800 | | 1339376400 | | 1339380000 | +------------+
I think I need to create a loop but I don’t know how to proceed from that. Thanks.
You could use a numbers table as Creating a "Numbers Table" in mysql that contains all hours for a considerate amount of time, and query that:
That makes the query really easy, and the table should not be too big, either. (Less than 90k rows for 10 years.)