Академический Документы
Профессиональный Документы
Культура Документы
SYNTAX:
FROM table_name.....
expressions....
EG:- SELECT*
FROM customers
WHERE salary= 20000;
The BETWEEN operator selects values within a range. The values can be numbers,
text, or dates.
SYNTAX:
SELECT column_name(s)
FROM table_name BETWEEN value1 AND value2;
Displays the values between the limit(upper limit and lower limit not included)
Displays the values that are not in between the limit(upper limit and lower limit
included)
############
ENAME
----------
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
ENAME
----------
SMITH
ALLEN
WARD
MARTIN
BLAKE
CLARK
SCOTT
TURNER
ADAMS
MILLER
Q. Display between l to z
A. SQL> SELECT ENAME
from emp
WHERE ENAME NOT BETWEEN 'A' AND 'L';
ENAME
----------
SMITH
WARD
MARTIN
SCOTT
TURNER
MILLER
ENAME
----------
SMITH
JONES
CLARK
SCOTT
KING
ADAMS
FORD
MILLER
Q. Display the employee name whose job is clerk and working in either 20 or 30 dept
A. SQL> SELECT ENAME DEPTNO
2 FROM emp
3 WHERE DEPTNO IN(20,30) AND JOB='CLERK';
DEPTNO
----------
SMITH
ADAMS
JAMES
Q. Display the employee name and salary whose job is salesman between 1000-3000
A. SQL> SELECT ENAME,SAL
2 from emp
3 WHERE SAL BETWEEN 1000 AND 3000
4 AND JOB='SALESMAN';
ENAME SAL
---------- ----------
ALLEN 1600
WARD 1250
MARTIN 1250
TURNER 1500
***********
1. When you want to see all employees whose name starts with S char. Then you can
use LIKE condition as follows
EG; select * from emp where ename like 's%'
2. you want to see all employees whose name ends with "d"
EG: SELect * FROM EMP WHERE ENAME like '%d';
3. you want to see all employees whose name starts with'A' and ends with 'd' like
'Abid'
EG: select * from emp where ename like 'A%d';
6. To see those employees whose name contains 'a' as last second character.
EG: select * from emp where ename like '%a_';
*********