Geek Slack

My SQL Tutorial
About Lesson


MySQL BETWEEN Operator


MySQL BETWEEN Operator

The BETWEEN operator in MySQL is used to retrieve rows that are within a specified range. It allows you to filter results based on inclusive values.

Example:

SELECT * FROM products WHERE price BETWEEN 100 AND 200;

This query will retrieve products whose price falls between $100 and $200, inclusive.

Using NOT BETWEEN:

The NOT BETWEEN operator is used to retrieve rows that are outside of a specified range.

SELECT * FROM products WHERE price NOT BETWEEN 50 AND 100;

This query will retrieve products whose price is not between $50 and $100.

The BETWEEN operator is convenient for filtering data within a defined range in MySQL queries.

Join the conversation