Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL Joins Exercises: Find the name, job, department ID and name of the employees who works in London

MySQL Joins: Exercise-3 with Solution

Write a query to find the name (first_name, last_name), job, department ID and name of the employees who works in London.

Sample table: employees


Sample table: departments


Sample table: locations


Code:

SELECT e.first_name, e.last_name, e.job_id, e.department_id, d.department_name 
FROM employees e 
JOIN departments d 
ON (e.department_id = d.department_id) 
JOIN locations l ON 
(d.location_id = l.location_id) 
WHERE LOWER(l.city) = 'London';

Sample Output:

first_name	last_name	job_id	department_id	department_name
Susan		Mavris		HR_REP	40		Human Resources

 

MySQL Code Editor:

Structure of 'hr' database :

hr database

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous:Write a query to find the name (first_name, last name), department ID and name of all the employees.
Next:Write a query to find the employee id, name (last_name) along with their manager_id and name (last_name).