• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
September 22, 2022 |490 Views
SQL | BETWEEN & IN Operator
  Share  1 Like
Description
Discussion

IN condition is used with the where statement just same as OR command, the only difference is for multiple values in OR condition we have to specify a lot of values but IN condition reduces the need of multiple OR in a SELECT, INSERT, UPDATE, or DELETE statement. 

The syntax for IN condition: 
SELECT “column_name” 
FROM “table_name” 
WHERE “column_name” IN (‘value1’, ‘value2’,....); 

BETWEEN condition is used to retrieve values within a particular range in a SELECT, INSERT, UPDATE, or DELETE statement. Here we need to specify a lower value and an upper value and between which the result will be given back. AND statement can be used as an alternative to BETWEEN command but the only difference is AND statement requires multiple statements which becomes complex when used for large data set. 

The syntax for BETWEEN condition: 
SELECT “column_name” 
FROM “table_name” 
WHERE “column_name” BETWEEN ‘value1’ AND ‘value2’; 

BETWEEN uses a particular data range to retrieve the value and the retrieved data set is within a lower and upper value, whereas IN is used to check the values in a specific set. BETWEEN can be used with AND whereas IN can be an alternative to OR.

SQL | BETWEEN & IN Operator: https://www.geeksforgeeks.org/sql-between-in-operator/

Read More