Francesc
Francesc

Reputation: 1349

MySQL Query between two items

I have a table which has 4 columns: id, twitter_id, date, time. I'd like to select all the rows which date value is 17-03-09 and the time, that they are between 9:00 and 9:59.
Is that possible with MySQL? How can I do it?

Upvotes: 1

Views: 65

Answers (2)

Brad Christie
Brad Christie

Reputation: 101604

SELECT    *
FROM      your_table
WHERE     date = '2009-03-17'
  AND     HOUR(time) = 9

possibly, assuming you mean 9am. If you mean PM, switch the condition to 21

Upvotes: 2

Phil Hunt
Phil Hunt

Reputation: 8521

SELECT `id`, `twitter_id`, `date`, `time`
FROM `table_name`
WHERE `date` = '2009-03-17' AND `time` >= '9:00' AND `time` < '10:00'

Upvotes: 2

Related Questions