Last answered:

13 Sept 2023

Posted on:

12 Sept 2023

0

INNER Join exercise solution code resolve

i used that code and joined three tables and get result includes the title

SELECT 
    m.emp_no,
    m.first_name,
    m.last_name,
    m.hire_date,
    c.title,
    d.dept_no
FROM
    employees m,
    titles_dup c
        INNER JOIN
    departments_dup2 d ON emp_no = emp_no
;


# the wirte solution
SELECT

    e.emp_no,

    e.first_name,

    e.last_name,

    dm.dept_no,

    e.hire_date

FROM

    employees e

        JOIN

    dept_manager dm ON e.emp_no = dm.emp_no;


1 answers ( 0 marked as helpful)
Instructor
Posted on:

13 Sept 2023

0

Hi Hazem!
Thanks for reaching out.


If you would like to use these three tables you have to make INNER JOIN between them and using the WHERE clause where you filter the managers.

SELECT 
    e.emp_no,
    e.first_name,
    e.last_name,
    e.hire_date,
    t.title,
    dm.dept_no
FROM
    employees e
        INNER JOIN
    dept_manager dm ON e.emp_no = dm.emp_no
        INNER JOIN
    titles t ON e.emp_no = t.emp_no
WHERE
    t.title = 'Manager';


Hope this helps.
Best,
Tsvetelin

Submit an answer