MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers

MySQL Between Operator

The MySQL Between operator is used to fetch values within a given range. It can be used with SELECT, INSERT, UPDATE and DELETE statement.

Note: When using the MySQL BETWEEN Operator with dates, use the CAST function to explicitly convert the values to dates.

MySQL Between OPERATOR Syntax

To fetch values within a given range, use the following syntax:


SELECT col1, col2, ...
FROM tablename
WHERE expression BETWEEN value1 AND value2; 


tablename: The table name from which you want to perform BETWEEN operator.

expression: Specifies a column name.

value1 AND value2: To define a range that expression is compared to.

MySQL Between OPERATOR example

The following MySQL, BETWEEN operator is used to fetch values within a given range i.e. "pk" BETWEEN 1 and 3:


SELECT firstName, lastName, address FROM tblCustomerLoan


In the above example, we are fetching values BETWEEN given range, in abobe example "pk" between 1 and 3.

You can use MySQL Command Line Client to fetch values within a given range. It will look like this: