Reputation: 1
New to MySql and am trying to query a table to get just certain hours and minutes such as
05:00:00. Have been using following, but only getting the 05:00:00 hours but need both 05 and 11 hours...
SELECT * FROM `UMHMwind`
WHERE Hour(`dt`) = "05,11" AND MINUTE(`dt`) = "0".
Probably a simple solution but have been unable to find anything helpful online.
Upvotes: 0
Views: 33
Reputation: 2267
You want to check a value is equal to either a value OR another (I mean hours in this case): you can use:
... where HOUR(dt) = 5 or HOUR(dt) = 11 ...
... where HOUR(dt) in (5, 11) ...
The second is a short-hand, so I suggest it.
Upvotes: 0
Reputation: 1270653
The correct syntax is:
SELECT *
FROM UMHMwind
WHERE Hour(dt) IN (5, 11) AND MINUTE(dt) = 0
Note that the hour()
and minute()
function return integers, so you should compare the results to integers.
Upvotes: 1