w3resource

SQL Subquery Exercises: Display all the information of an employee whose id is any of the number 134, 159 and 183

SQL SUBQUERY: Exercise-8 with Solution

From the following table, write a SQL query to find those employees whose ID matches any of the numbers 134, 159 and 183. Return all the fields.

Sample table: employees


Sample Solution:

SELECT * 
FROM employees 
WHERE employee_id IN (134,159,183);

Sample Output:

employee_id	first_name	last_name	email	phone_number 		hire_date	job_id 	salary commission_pct	manager_id	department_id
134		Michael		Rogers		MROGERS	650.127.1834		2006-08-26	ST_CLERK	2900.00	  0.00		122		50
159		Lindsey		Smith		LSMITH	011.44.1345.729268	2005-03-10	SA_REP		8000.00   0.30		146		80
183		Girard		Geoni		GGEONI	650.507.9879		2008-02-03	SH_CLERK	2800.00	  0.00		120		50

Relational Algebra Expression:

Relational Algebra Expression: Display all the information of an employee whose id is any of the number 134, 159 and 183.

Relational Algebra Tree:

Relational Algebra Tree: Display all the information of an employee whose id is any of the number 134, 159 and 183.

Pictorial Presentation:

SQL Subqueries: Display all the information of an employee whose id is any of the number 134, 159 and 183

Practice Online


Query Visualization:

Duration:

Query visualization of Display all the information of an employee whose id is any of the number 134, 159 and 183 - Duration

Rows:

Query visualization of Display all the information of an employee whose id is any of the number 134, 159 and 183 - Rows

Cost:

Query visualization of Display all the information of an employee whose id is any of the number 134, 159 and 183 - Cost

Contribute your code and comments through Disqus.

Previous: Write a query to display all the information of an employee whose salary and reporting person id is 3000 and 121 respectively.
Next:From the following table, write a SQL query to find those employees whose salary is in the range 1000, and 3000 (Begin and end values have included.). Return all the fields.

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