/*the BETWEEN operator is used to filter the result set within
a certain range. the values can be numbers, texts or dates */
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
BETWEEN wählt Werte innerhalb eines bestimmten Bereichs aus.
Die Werte können Zahlen, Text oder Datumsangaben sein.
SELECT column_name(s)
FROM table_name
WHERE
column_name BETWEEN value1 AND value2;
• BETWEEN operator is used to display
rows based on a range of values in a
row whereas the IN condition operator
is used to check for values contained
in a specific set of values.
• Example of BETWEEN:
SELECT * FROM Students
WHERE ROLL_NO BETWEEN 10 AND 50;
• Example of BETWEEN:
SELECT * FROM students
WHERE ROLL_NO IN (8,15,25);
-- The difference is that BETWEEN will search for all the values that fall
-- between the mentioned lower and upper bound.
-- However, IN will only search for the mentioned list of values in your DB.
select Name from Student where Marks between 75 and 100
-- BETWEEN allows you to test if an expression is within a range of values
-- (inclusive). In our case the value has to be >=75 & <=100
select Name from Student where Marks in (75,80,85,90,95,100)
-- IN allows you to test if the expression matches any value
-- in the list of values.
-- NOTE: If a student has lets say 81 marks, they will appear after the
-- line having BETWEEN operator is executed, but not when the line having
-- IN operator is executed.
Selects values within the given range.
Example 1: Selects stock with a quantity between 100 and 150.
SELECT * FROM stock
WHERE quantity BETWEEN 100 AND 150;
Example 2: Selects stock with a quantity NOT between 100 and 150.
Alternatively, using the NOT keyword here reverses the logic and selects
values outside the given range.
SELECT * FROM stock
WHERE quantity NOT BETWEEN 100 AND 150;
#The BETWEEN operator selects a range of data between two values. The values can be numbers,
#text, or dates.
syntax->SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
///example///
SELECT * FROM Persons
WHERE LastName
BETWEEN 'Hansen' AND 'Pettersen'