Sunday, September 7, 2014

Subquery

A subquery is a query that is wrapped within another query. It's also called an INNER query.

SELECT mc.first_name, mc.last_name, mc.phone, jc.title
FROM job_current AS jc NATURAL JOIN my_contacts AS mc
WHERE jc.title IN (SELECT title FROM job_listings);

SELECT some_column, another_column
FROM table
WHERE column = (SELECT column FROM table)

Correlated subqueries

In a non correlated subquery the inner query, or subquery, gets interpreted by the RDBMS followed by the outer query.

SELECT mc.first_

No comments:

Post a Comment