Expressing Conditions in Different Ways

One side benefit to everything you’ve learned in this chapter is that you now have the ability to express a given condition in various ways. Let’s take a look at this by considering the following request.

“Give me the name of every employee who was hired in October 2007.”

You need to search for hire dates that fall between October 1, 2007, and October 31, 2007, in order to answer this request. Based on what you’ve already learned, you can define the condition in two ways.

DateHired BETWEEN '2007-10-01' AND '2007-10-31'
DateHired >= '2007-10-01' AND DateHired <= '2007-10-31'

Both of these conditions will send the same rows to the result set—the condition you choose to use is only a matter of preference. ...

Get SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.