BETWEEN AND Operator in SQL Query with Example

Опубликовано: 29 Март 2026
на канале: WingsOfTechnology
3,278
7

SQL BETWEEN ... AND Operator:

The operator BETWEEN and AND, are used to compare data for a range of values.

For Example: to find the emp details who have salaries between 2500 and 5000, the query would be like,

select * from emp where sal between 2500 and 5000;

The output would be similar to:

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7902 FORD ANALYST 7566 03-DEC-81 3000 20