SQL Server – SELECT Statement with WHERE BETWEEN clause

SELECT Statement with WHERE BETWEEN clause

The BETWEEN clause with WHERE is used as search condition for finding values within a range.

The BETWEEN clause is the shorthand for “greater than or equal ( >= ) to the first value, and less then or equal to the second value ( <= )”.

Example:

USE AdventureWorks

SELECT * FROM Sales.CreditCard

WHERE CreditCardID

BETWEEN 15 AND 35

The BETWEEN search condition is commonly used with dates.

Example:

USE AdventureWorks

SELECT * FROM Sales.CreditCard

WHERE ModifiedDate

BETWEEN ’01-08-2003′ AND ’03-30-2003′

See also:

DML SELECT Statement

SELECT Statement with WHERE clause

SELECT Statement with WHERE IN clause

Good Luck!

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

%d bloggers like this: