Determines whether a value is within a specified range defined by two boundaries.

Syntax

expression [ NOT ] BETWEEN compValue1 AND compvalue2

Arguments

  • expression: the expression to evaluate.

  • compValue1: the boundaries (inclusive) of the comparison range. compValue1 should be lower than compValue2.

Returns

  • The row or value, when the evaluation is true.

Additional Information

  • expression must be of a type which can be compared using >= or <= operators.

  • Cast compValue1 and compValue2 as necessary to match expression’s type.

Examples

SELECT cust_id, saledate, amnt FROM MYSQL.inventory.cust_sales
WHERE aledate BETWEEN DATE('2005-01-01') AND DATE('2010-12-31');

VALUES 2008 BETWEEN 2000 AND 2010;
-- Returns true