How To Use Subqueries with the IN Operator using Oracle?
Submitted by: AdministratorA subquery can be used with the IN operator as "expression IN (subquery)". The subquery should return a single column with one or more rows to form a list of values to be used by the IN operation. The following tutorial exercise shows you how to use a subquery with the IN operator:
SQL> SELECT first_name, last_name FROM employees
2 WHERE department_id IN (
3 SELECT department_id FROM departments
4 WHERE location_id = 1700
5 );
<pre>FIRST_NAME LAST_NAME
-------------------- -------------------------
Steven King
Neena Kochhar
Lex De Haan
Nancy Greenberg
Daniel Faviet
John Chen
Ismael Sciarra
......</pre>
Submitted by: Administrator
SQL> SELECT first_name, last_name FROM employees
2 WHERE department_id IN (
3 SELECT department_id FROM departments
4 WHERE location_id = 1700
5 );
<pre>FIRST_NAME LAST_NAME
-------------------- -------------------------
Steven King
Neena Kochhar
Lex De Haan
Nancy Greenberg
Daniel Faviet
John Chen
Ismael Sciarra
......</pre>
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How Much Memory Your 10g XE Server Is Using? |
☺ | What Is the Relation of a User Account and a Schema? |
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
☺ | What Is Input Buffer in SQL*Plus? |
☺ | What Happens to Indexes If You Drop a Table? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |