SQL: Using BETWEEN

 

SQL: Using the BETWEEN Operator

BETWEEN
Introduction

 

  • BETWEEN is an operator that acts on a column and two values
  • If a row’s column value is “between” these two values, the expression evaluates to TRUE
  • BETWEEN is inclusive, it includes the two values in the calculation of what is “between”

Example:

Who are all the people in my contact list that I have contacted at least once but no more than 20 times?
SELECT p.person_first_name

FROM person p WHERE p.contacted BETWEEN 1 AND 20;

More Examples:

BETWEEN_Terminal

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s