I have the following select to pick up the time of day
SELECT '00:00' AS A UNION
SELECT '01:00' UNION
SELECT '02:00' UNION
SELECT '03:00' UNION
SELECT '04:00' UNION
SELECT '05:00' UNION
SELECT '06:00' UNION
SELECT '07:00' UNION
SELECT '08:00' UNION
SELECT '09:00' UNION
SELECT '10:00' UNION
SELECT '11:00' UNION
SELECT '12:00' UNION
SELECT '13:00' UNION
SELECT '14:00' UNION
SELECT '15:00' UNION
SELECT '16:00' UNION
SELECT '17:00' UNION
SELECT '18:00' UNION
SELECT '19:00' UNION
SELECT '20:00' UNION
SELECT '01:00' UNION
SELECT '22:00' UNION
SELECT '23:00'
Is there any simpler to do this?
Because it seems like putting this query together like the one I want to do is kind of slow.
For example:
SELECT * FROM(
SELECT * FROM (
SELECT '00:00' AS A UNION
SELECT '01:00' UNION
SELECT '02:00' UNION
SELECT '03:00' UNION
SELECT '04:00' UNION
SELECT '05:00' UNION
SELECT '06:00' UNION
SELECT '07:00' UNION
SELECT '08:00' UNION
SELECT '09:00' UNION
SELECT '10:00' UNION
SELECT '11:00' UNION
SELECT '12:00' UNION
SELECT '13:00' UNION
SELECT '14:00' UNION
SELECT '15:00' UNION
SELECT '16:00' UNION
SELECT '17:00' UNION
SELECT '18:00' UNION
SELECT '19:00' UNION
SELECT '20:00' UNION
SELECT '01:00' UNION
SELECT '22:00' UNION
SELECT '23:00'
) A
)A
LEFT JOIN( SELECT DATE_FORMAT( date, '%H:%i' ) HORA
,TRUNCATE( MAX( humidade ),2 ) MAX_HUMIDADE
,TRUNCATE( MIN( humidade ),2 ) MIN_HUMIDADE
FROM medicao
WHERE DATE(date) = ?
GROUP BY HOUR(date)
) B ON B.HORA = A.A
Type one last_day to get the last date of the month