﻿ SQL SUBQUERIES: Find those employees whose department is located at ‘Toronto’ - w3resource

# SQL Subquery Exercises: Display the employee name, employee id, and job title for all employees whose department location is Toronto

## SQL SUBQUERY: Exercise-16 with Solution

From the following table, write a SQL query to find those employees whose department is located at ‘Toronto’. Return first name, last name, employee ID, job ID.

Sample table: employees

Sample table: departments

Sample table: locations

Sample Solution:

``````SELECT  first_name, last_name, employee_id, job_id
FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE location_id =
(SELECT location_id
FROM locations
WHERE city ='Toronto'));
``````

Sample Output:

```first_name	last_name	employee_id	job_id
Michael		Hartstein	201		MK_MAN
Pat		Fay		202		MK_REP
```

Pictorial Presentation:

## Query Visualization:

Duration:

Rows:

Cost:

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?

﻿

## SQL: Tips of the Day

"where 1=1" statement?

It's usually when folks build up SQL statements.

When you add and value = "Toyota" you don't have to worry about whether there is a condition before or just WHERE.

Ref: https://bit.ly/3cayyhJ