Goal: Search all users who were updated between a certain time period (in our case one day).
Scenario: A system wide glitch caused a set of users to have all of their last names changed to Smith. Your manager wants to know how many records are affected.
MySQL offers 2 or more ways this can be accomplished. First using <= and >= the second using BETWEEN operator.
The between operator is identical to >= and <= and is inclusive. Notice the difference in order between the 2 queries.
In order for this query to work the field must be either datetime, timestamp, or date. If using date then remove the time portion from the query.
Demo on SQL Fiddle.
Share this Story