SQL BETWEEN Operator: Select Values Within a Range - Comprehensive Guide
The SQL BETWEEN operator is used to select values within a range. It is often used in conjunction with the WHERE clause to filter rows based on a range of values.
The syntax of the BETWEEN operator is:
SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;
For example, if we have a table named 'employees' with a column 'salary', and we want to select all employees with a salary between $50,000 and $80,000, we can use the following SQL statement:
SELECT * FROM employees WHERE salary BETWEEN 50000 AND 80000;
This will return all rows from the 'employees' table where the salary is between $50,000 and $80,000.
原文地址: https://www.cveoy.top/t/topic/mXy3 著作权归作者所有。请勿转载和采集!