Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

mysql finding out who has the same job as x

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;)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Is this what you are looking for?

http://sqlfiddle.com/#!9/0a1369/3

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading