Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL IN Operator      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: IN

Definition:
The Oracle PL/SQL IN operator allows testing a term of a condition by comparing it for equality with a list of fixed values. The condition defined using the IN operator is also known as the membership condition. IN works with values of all data types. When using characters, dates, or other non-numeric strings, the list items must be enclosed with single quotation marks (for example, '2010-09-22'), as shown in the second example below.

Example Syntax:

SELECT * 
FROM EMPLOYEES
WHERE SALARY IN (1500, 3000, 2500)

In the query above, Oracle would select only those records where the salary is equal to either 1500, or 3000, or 2500. It would not match a salary of '1800'.


SELECT * 
FROM EMPLOYEES
WHERE CITY IN ('Seattle', 'Memphis', 'Los Angeles')

In the query above, Oracle would select only those records where the CITY is equal to 'Seattle', 'Memphis', or 'Los Angeles'. Note that the list items are enclosed with single quotation marks since they are non-numeric strings.

Similarly, the query below finds any employee whose last name is included in the list of names. The query selects those employees whose last name is SMITH, JONES, WILSON, or ROGERS.

SELECT LAST_NAME, SALARY, EMPNO
FROM EMPLOYEES
WHERE EMP_LNAME IN ('SMITH', 'JONES', 'WILSON', 'ROGERS');



Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 75 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?