SQL tutorial | Interview questions | Oracle
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How To Use Subqueries with the IN Operator?

Go down

How To Use Subqueries with the IN Operator? Empty How To Use Subqueries with the IN Operator?

Post by Micheal Sun Jan 17, 2010 3:18 am

A 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
WHERE department_id IN (
SELECT department_id FROM departments WHERE location_id = 1700
);
FIRST_NAME LAST_NAME
-------------------- -------------------------
Steven King
Neena Kochhar
Lex De Haan
Nancy Greenberg
Daniel Faviet
John Chen
Ismael Sciarra

Micheal
Admin

Posts : 243
Join date : 2010-01-10

http://sql-tutorial.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum