Regarding the lecture about SELF JOINs I was wondering if the JOIN clause is necessary.
Following logic in the last solution using WHERE IN I created a query as follows:
emp_no IN (SELECT
The connection is also only in two rows of interest and the result is same.
Is this solution correct? Are there some cases, in which SELF JOIN would be necessary?
Thanks for reaching out.
The cases in which using a self-join can be advantageous have been described in the lecture. In this particular example, so long as you obtain the same output, then your query is more than valid. Thank you very much for sharing an alternative.
Why do we use a self-join in this lecture? Because we wanted to teach you how to use this tool. Otherwise, it is true that sometimes identical output can be obtained by using different queries.
Hope this helps.
I understand, thank you 🙂 . May I have one more question? Could be the solution with Self Join more efficient in term of time? If yes, maybe I should prefer the solution form your lecture in the future. Best, Maros.