Home > Blockchain >  use subquery to show JOB_TITLE
use subquery to show JOB_TITLE

Time:09-12

i tried to use subquery to show JOB_TITLE in the result this code work , but i can't add JOB_TITLE 'Jr. Designer' in the result

select EMP_ID,F_NAME,L_NAME
from employees
where job_id in (select job_ident from jobs where JOB_TITLE= 'Jr. Designer'); 

CodePudding user response:

First run this by itself

select job_ident from jobs where JOB_TITLE= 'Jr. Designer'

do you get any rows back? if not, then the text does not match and you should fix that.

JOB_ID on the employees table seems like a bad normalization. I'm supposing that is where it is located or you would get some error that you would post here. I would suggest normalizing that correctly in either case.

CodePudding user response:

Instead ofr an IN clause use JOIN

select EMP_ID,F_NAME,L_NAME,JOB_TITLE
from employees e INNER JOIN jobs j ON j.job_ident = e.job_id
where JOB_TITLE= 'Jr. Designer';

 
  • Related