MySQL Between Operator

In order to select data that is within a range of values, the BETWEEN operator is used. The BETWEEN operator allows the selection of rows that contain values with a specified lower and upper limit. The range coded after the word BETWEEN is inclusive.

The Lower value must be coded first. The two values in between the range must be linked with the keyword AND. The BETWEEN operator can be used with both character and numeric data types. However, the data types cannot be mixed i.e. the lower value of a range of values from a character column and other from a numeric column.


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

Ex: MySQL Table tblemployee

1Anuj Kumar108061212018-05-01
2Sanjeev Kumar19087632018-08-10
3Jonh Doe108997812017-01-01


SELECT Emp_Name,Emp_Code from tblemployee WHERE id BETWEEN 2 and 3;


2Sanjeev Kumar19087632018-08-10
3Jonh Doe108997812017-01-01

Ex2 :

SELECT Emp_Name,Emp_Code from tblemployee WHERE Emp_JoiningDate BETWEEN '2016-12-01' and '2018-07-01';

Output :

1Anuj Kumar108061212018-05-01
3Jonh Doe108997812017-01-01

To find those employees whose id not between 1 and 2 , you can use BETWEEN operator with the NOT Operators as follows :

SELECT Emp_Name,Emp_Code from tblemployee WHERE id NOT BETWEEN 2 and 3;


1Anuj Kumar108061212018-05-01

Anuj Kumar

This is Anuj Kumar. I’m a professional web developer with 4+ year experience. I write blogs in my free time. I love to learn new technologies and share with others.
I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials.

Recommended Tutorials for you

Add comment

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

Web Hosting with a FREE domain. On sale ₹99.00/mo

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.