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