BETWEEN Operator

The BETWEEN operator is used to filter records within a specified range. It includes the boundary values.

Example: Using BETWEEN

SELECT Name, BirthDate
FROM FreedomFighters
WHERE BirthDate BETWEEN '1900-01-01' AND '1950-12-31';

Output:

Returns the names and birth dates of freedom fighters born between 1900 and 1950.

Do's and Don'ts

Do's

  • Use BETWEEN for easy range filtering in queries.
  • Ensure the range boundaries are correct and meaningful.

Don'ts

  • Don't use BETWEEN for date ranges without confirming the inclusivity of boundary values.
  • Don't forget to handle cases where the data may fall outside the specified range.