The best way to view self join is create two tables and then view the joining conditions.
Table t1
Id Related
1 null
2 1
4 1
Table t2
Id Related
1 null
2 1
4 1
Note: Left Join means every thing from left table will come even if joining condition does not match. From the right table it will come as null.
First Query: t1.related = t2.id; (Columns selected "t1.id, t2.id")
1.) Lets take first row from t1 table and related column has null value. null has not match in id column of t2 table. As it is a left join, row will come from t1 table.
First Row:
t1_id t2_id
1 null
2.) Lets take second row from t1 table and related column has 1. 1 has one match in id column of t2 table. So one row comes in join condition.
Second Row:
t1_id t2_id
2 1
3.) Lets take third row from t1 table and related column has 1. 1 has one match in id column of t2 table. So one row comes in join condition.
Third Row:
t1_id t2_id
4 1
Second Query t1.id = t2.related (Columns selected "t1.id, t2.id")
1.) Lets take first row from t1 table and id column has 1. 1 has 2 rows in related column of t2 table. so two rows are selected.
t1.id t2.id
1 2
1 4
2.) Lets take second row from t1 table and id column has 2. 2 has 0 row in related column of t2 table. But it a left join row will come fro t1 table.
t1.id t2.id
1 2
1 4
2 null
2.) Lets take third row from t1 table and id column has 4. 4 has 0 row in related column of t2 table. But it a left join row will come fro t1 table.
t1.id t2.id
1 2
1 4
2 null
4 null
Hope this will make you understand.
Thanks
Ankit.