Why left join on is not returning the not-matching records?


This Content is from Stack Overflow. Question asked by testy

select sr.Name, srj.Name as ParentSR from Role sr
left join Role srj
on sr.id= srj.ParentRoleId
where sr.isDeleted= 0 and srj.isDeleted= 0

now I have 190 records and among which only 40 have ParentRoleId but when I run this query it returns me only 40 the same which have only parentID but not the ones with ParentRoleID = NULL.
I want it to return every row from the Role sr but it’s not happening.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?