Sql Between Operator

BETWEEN OPERATOR:-  The BETWEEN operator is used to select values within a given range. The range consists of a beginning, followed by an AND keyword and an end expression. In this operator, value is TRUE if the search value present within the range otherwise returns FALSE.

SYNTAX:-

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2 ; 

EXAMPLE:-  

Consider the table  STUDENT having following records:-


The following SQL statement selects all students with an Age BETWEEN 20 and 25:-

SELECT StudentID , Name , Age
FROM STUDENT 
WHERE Age BETWEEN 20 AND 25 ;

OUTPUT:-


NOT BETWEEN Example:-

To display the products outside the range of the previous example, use NOT BETWEEN:-

SELECT StudentID , Name , Age
FROM STUDENT 
WHERE Age  NOT BETWEEN 20 AND 25 ;

OUTPUT:- 


Comments

Popular posts from this blog

ASP.NET Overview

SQL AND ,OR, NOT Operators

SQL Joins