Javatpoint Logo
Javatpoint Logo

MySQL BETWEEN Condition

The MYSQL BETWEEN condition specifies how to retrieve values from an expression within a specific range. It is used with SELECT, INSERT, UPDATE and DELETE statement.

Syntax:

Parameters

expression: It specifies a column.

value1 and value2: These values define an inclusive range that expression is compared to.

Let's take some examples:

(i) MySQL BETWEEN condition with numeric value:

Consider a table "officers" having the following data.

MySQL BETWEEN 1

Execute the following query:

Output:

MySQL BETWEEN 2

Note: In the above example, you can see that only three rows are returned between 1 and 3.

(ii) MySQL BETWEEN condition with date:

MySQL BETWEEN condition also facilitates you to retrieve records according to date.

See this example:

Consider a table "employees", having the following data.

MySQL BETWEEN 3

Execute the following query:

Output:

MySQL BETWEEN 4

Note: In the above example you can see that only data between specific dates are shown.

Next TopicMySQL JOIN




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA