Subscribe:

Thursday, September 29, 2011

IN

IN 

IN Operator used to restrict rows retrieved to values in specified list
The IN keyword is followed by values separated by commas.
The full list of values is enclosed within a single set of parentheses.
Also you can use IN with any data type  (character, numeric, dates).
For example
Select empno,ename,sal
From emp
Where sal in (125,3000,1600);
EMPNO ENAME             SAL
------ ---------- ----------
  7499 ALLEN            1600
  7788 SCOTT            3000
  7902 FORD             3000

SELECT ENAME,SAL,JOB
FROM EMP
WHERE JOB IN (‘MANAGER’,’ANALYST’,’PRESIDENT’)
ENAME             SAL JOB
---------- ---------- ---------
JONES            2975 MANAGER
BLAKE            2850 MANAGER
CLARK            2450 MANAGER
SCOTT            3000 ANALYST
KING              5000 PRESIDENT
FORD             3000 ANALYST

No comments:

Post a Comment