Other related articles:

Recently viewed articles:

SQL BETWEEN Keyword

The BETWEEN operator is very useful operator when you have to find information falling into certain range, that is between two values. An alternative way to check for a value within a certain range is to use the “greater than or equal to” (>=) operator  or the “less than or equal to” (<=) operator.

The BETWEEN operator performs exactly the same way, but it’s much shorter and also makes the SQL statement more readable. The SQL statement below uses the BETWEEN operator to select employees who joined between certain period of time:

 SELECT ename

FROM emp

WHERE DOJ BETWEEN ‘’ AND ‘’

IMAGE

BETWEEN operator is Inclusive Opertor which means it also includes data for values given in range. We can use BETWEEN operator with all data types such as numbers, such as text and dates. Now imagine a situation where you need to find values which does not fall in certain range. For this purpose, we can use BETWEEN operator in combination with NOT operator, with which SQL statement will select the values that are not in the range given in query.

SELECT ename

FROM emp

WHERE DOJ NOT BETWEEN ‘’ AND ‘’

IMAGE