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 :
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).
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework