i have this table (SELECT ename, job FROM emp;)
| ename | job |
|---|---|
| Smith | Clerk |
| Allen | Salesman |
| Ward | Salesman |
| Jones | Manager |
| Martin | Salesman |
| Blake | Manager |
| Clark | Manager |
| Scott | Analyst |
| King | President |
| Turner | Salesman |
| Adams | Clerk |
| James | Clerk |
| Ford | Analyst |
| Miller | Clerk |
i want to find out who has the same job as Jones. Jones is a manager so the table i want should look like this:
| ename | job |
|---|---|
| Jones | Manager |
| Blake | Manager |
| Clark | Manager |
I cant figure out what to use. The obvious is (SELECT ename, job FROM emp where job ="Manager";)
But I am not looking for who is the manager, but who has the same job as Jones. I have to use a subquery of some sort, but i dont know how it functions. Hope one of you can help me;)
>Solution :
Is this what you are looking for?
http://sqlfiddle.com/#!9/0a1369/3