Sub Queries

A sub-query is a select query that is contained inside another query. The inner select query is usually used to determine the results of the outer select query.

Using Murach Database, find employees who work in Payroll Department.

use Murach;

select 
    department_number
from 
    departments 
where 
    department_name = 'Payroll';

SELECT 
    * 
FROM 
    employees 
where 
    department_number = Value from previous query;

Now using Subquery

Using Chinook database, simple Subquery to find out Names of Support Representative

Using Sakila database, find the actors who acted in the movie Ace Goldfinger

Last updated