9

MariaDB 10.1.x

Let's say I have a query like:

select FOO from db.BLAH where STAMPFOO > NOW() - INTERVAL 1 HOUR

If I run that query at 12:15 PM, will I only get records that have a date value greater than 11:15 AM? Or greater than 11:00 AM?

Mike B
  • 617
  • 4
  • 10
  • 17

1 Answers1

9

Since the WHERE clause says NOW(), the expression STAMPFOO > NOW() - INTERVAL 1 HOUR makes this a dynamic query. It will return all records whose timestamp is greater than one hour ago, down to the very second.

If you run this at 2017-02-02 12:15:27, your query will return all FOO values from 2017-02-02 11:15:27.

RolandoMySQLDBA
  • 185,223
  • 33
  • 326
  • 536