Invalid SQL (INNER JOIN) indenter error

Asked

Viewed 350 times

0

  1. Select a list of employees who have changed positions or departments (job_history), the list must contain the employee’s registration and name, the name of the department and position that worked, and also the start date and end date (start_date and end_date), sort by the start date.

Make a select with Inner Join using Where and another select with Join....

R:

select 
    E.employee_id, 
    E.first_name||' '||E.last_name "Nome", 
    D.department_name, 
    J.job_title, 
    JH.start_date, 
    JH.end_date
from employees E, job_history JH, jobs J
inner join departments D on E.employee_id = JH.employee_id 
                         and D.department_id = JH.department_id 
                         and J.job_id = JH.job_id
order by JH.start_date;

ORA-00904: "JH"." JOB_ID": invalid identifier 00904. 00000 - "%s: invalid Dentifier" *Cause:
*Action: Error on line: 18 Column: 114

inserir a descrição da imagem aqui

  • puts the job_history and jobs also in the join

  • Syntax error, see how to do Inner Join with 3 tables or more.

1 answer

0


try to make a Join for each relationship, like.

select 
E.employee_id, 
E.first_name||' '||E.last_name "Nome", 
D.department_name, 
J.job_title, 
JH.start_date, 
JH.end_date
from 
employees E inner join departments D on E.department_id = D.department_id,
job_history JH inner join departments D on JH.department_id = 
D.department_id, jobs J inner join departments D on J.department_id = 
D.department_id,
.
.
.
order by JH.start_date;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.