w3resource
SQL exercises

SQL Subquery Exercises: Display the city of the employee whose ID 134 and works there

SQL SUBQUERY: Exercise-47 with Solution

Write a query in SQL to display the city of the employee whose ID 134 and works there.

Sample table: locations


Sample table: departments


Sample table: employees


Sample Solution:

SELECT city 
	FROM locations 
		WHERE location_id = 
    (SELECT location_id 
		FROM departments 
			WHERE department_id =
             	(SELECT department_id 
					FROM employees 
						WHERE employee_id=134));

Sample Output:

city
South San Francisco

Practice Online


Query Visualization:

Duration:

Query visualization of Display the city of the employee whose ID 134 and works there - Duration

Rows:

Query visualization of Display the city of the employee whose ID 134 and works there - Rows

Cost:

Query visualization of Display the city of the employee whose ID 134 and works there - Cost

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

Previous: Write a query in SQL to display the first and last name, salary and department ID for those employees whose department is located in the city London.
Next: Write a query in SQL to display the the details of those departments which max salary is 7000 or above for those employees who already done one or more jobs.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming