Difference between In and Between Operator in SQL

Introduction

In this blog, I will describe the difference between In Operator and Between Operator. Both of these operators are used to find out the multiple values from the table. Differences between these operator is that the BETWEEN operator is used to select a range of data between two values while The IN operator allows you to specify multiple values.

Description

Here we are finding the multiple value by using the SQL. Here First we make a table which have six columns, So there is a table which is shown below :

6.jpg

  • BETWEEN Operator

The BETWEEN operator selects a range of data between two values. The values can be numbers, text,etc.

Syntax

SELECT * FROM table_name
WHERE column_name BETWEEN 'value1' AND 'value2'

Example

SELECT *FROM akash1

WHERE marks BETWEEN 50 AND 80

Output

7.jpg

 

  • IN Operator

The IN operator allows you to specify multiple values.

Syntax

SELECT * FROM table_name
WHERE column_name IN ('value1','value 2')

Example

SELECT * FROM akash1

WHERE marks IN (89,81)

Output

8.jpg