patternsqlMinor
What exactly is INTERVAL 1 HOUR checking?
Viewed 0 times
whathourintervalcheckingexactly
Problem
MariaDB 10.1.x
Let's say I have a query like:
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?
Let's say I have a query like:
select FOO from db.BLAH where STAMPFOO > NOW() - INTERVAL 1 HOURIf 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?
Solution
Since the
If you run this at
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.Context
StackExchange Database Administrators Q#163090, answer score: 8
Revisions (0)
No revisions yet.