Tutorialsplane

SQL Between

SQL Between Clause

SQL – Between Clause is used to select the between the two specified range.

SQL Between Clause Syntax

SELECT ColumnName1,ColumnName2… FROM TableName WHERE columnName BETWEEN Range1 AND Range2 ;

Suppose We Have the following Table :

Example

SELECT * FROM Users WHERE ID BETWEEN 5 AND 8 ;

Will Produce The Following Result :

SQL – NOT Between Clause Syntax-

NOT BETWEEN Clause selects only those records which does not come in the specified range.

SELECT ColumnName1,ColumnName2… FROM TableName WHERE columnName NOt BETWEEN Range1 AND Range2 ;

Example

SELECT * FROM Users WHERE ID NOT BETWEEN 5 AND 8 ;

Will Produce The Following Result :