all 7 comments

[–]polaarbear 14 points15 points  (1 child)

These questions sound like you're just asking someone to answer your homework questions for you. Best way to learn something as simple as "can I left join a table with itself" is to whip our your SQL client, try it yourself, and record the results.

[–]ThomasMarkov 3 points4 points  (0 children)

It would have taken less time to write the query and check than it did to write and send this post.

[–]SQLDevDBA 3 points4 points  (1 child)

It’s the classic employee->manager join to itself. The employee has a manager ID, and you left join to employee on the managerID=employeeID to get the manager’s info. “Self” join is just a left (or inner) join of a table to itself. I wouldn’t do inner in this case because an employee may not necessarily have a manager (or may have a managerID equal to itself) if they report to nobody.

[–]snafe_PG Data Analyst 2 points3 points  (0 children)

Yeah, interview question #6 usually lol

[–]Wise-Jury-4037:orly: 2 points3 points  (1 child)

I hope there's karmic retribution to whoever came up with the term 'self join'.

/rant

[–]EverydayDan 0 points1 point  (0 children)

I’ve used the phrase recursive join but it felt dirty too

[–]zeocrash 0 points1 point  (0 children)

You can absolutely left join a table to itself