BETWEEN


This operator is used to determine whether a value of an expression falls within a specific range of values
This operator is used in the WHERE clause.


SELECT     * 
FROM CATEGORIES
WHERE CategoryID BETWEEN 5 AND 10

The above works in Access and SQL Server because it is an numerical field



--This works in SQL Server (despite Extension being a text column) but not in Access

SELECT     * 
FROM EMPLOYEES
WHERE Extension BETWEEN 0 AND 2000


--This works in both SQL Server and Access
--The ROUND function converts the text field to a numerical value

SELECT     * 
FROM EMPLOYEES
WHERE ROUND(Extension,0) BETWEEN 0 AND 2000


This is equivalent to

WHERE      (CategoryID >= 5) AND (CategoryID <= 10) 

This returns all strings between "A" and "C" which includes any words starting with "A" or "B".

BETWEEN    ('A-C')  



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext