Between operator in SQL Query

Between Operator in SQL Query

Between operator is used to fetch data in specific range of value in one Statement instead of using greater than and equal to operator multiple time. It better to understand during reading and less mistake chance for user in defining range value.

Syntax

SELECT columnname FROM tablename WHERE columnname BETWEEN value1 AND value2;
>

Example
Find the value in the particular range from the table Employee having salary range inbetween 10000 to 20000.

select * from employee where salary between 10000 and 20000;

Find all the employee whose salary not in between 10000 to 20000

select * from employee where salary not between 10000 and 20000;

Find data range with between clause.
Find employees details how is joining inbetween 1-Aug-2000 to 31-Dec-2000.

select * from employees where joining_date between '1-AUG-2000' and '31-DEC-2000';

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.