Last answered:

13 Jun 2022

Posted on:

12 Jan 2022

0

Why is d.dept_no and dm.dept_no different in the first place?

d.dept_no and dm.dept_no both represent department numbers. Why is their values in the column different from the other?



image

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

04 Feb 2022

0

Hi Lifang!

Could you please support your question with the entire code you’ve executed? This can help us assist you better. Thank you.

Looking forward to your answer.
Best,
Tsvetelin








Posted on:

25 May 2022

0

Hello Team,

I notice same output. That's the code below,

SELECT
    dm.*, d.*
FROM
    dept_manager dm
        CROSS JOIN
    departments d
ORDER BY dm.emp_no , d.dept_no;

image

Instructor
Posted on:

13 Jun 2022

0

Hi Ashakah!
Thanks for reaching out.

This is because we make CROSS JOIN between the two tables, so every record from the first table will be joined with every record from the other table. So, emp_no 110022 has dept_no d001 but it is joined with all other departments. Thus, we have d001 - d001, d001 - d002, d001 - d003 and etc.

Hope this helps.
Best,
Tsvetelin

Submit an answer