﻿ SQL SUBQUERIES: Find those employees who report to that manager whose first name is ‘Payam’ - w3resource

# SQL Subquery Exercises: Display the employee name, employee id and salary of all employees who report to Payam

## SQL SUBQUERY: Exercise-5 with Solution

From the following table, write a SQL query to find those employees who report to that manager whose first name is ‘Payam’. Return first name, last name, employee ID and salary.

Sample table: employees

Sample Solution:

``````SELECT first_name, last_name, employee_id, salary
FROM employees
WHERE manager_id =
(SELECT employee_id
FROM employees
WHERE first_name = 'Payam'
);
``````

Sample Output:

```first_name	last_name	employee_id	salary
Jason		Mallin		133		3300.00
Michael		Rogers		134		2900.00
Ki		Gee		135		2400.00
Hazel		Philtanker	136		2200.00
Kelly		Chung		188		3800.00
Jennifer	Dilly		189		3600.00
Timothy		Gates		190		2900.00
Randall		Perkins		191		2500.00
```

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