+ 2

Left Join and Right Join Difference

What is the difference between LEFT JOIN and RIGHT JOIN in SQL? Please give me an example or anything related to this. Thanks!

1st Oct 2017, 4:24 AM
Aurelio Pantaleon II
Aurelio Pantaleon II - avatar
2 Respostas
+ 3
select m.name, f.name from men m left join women f on m.spouse=f.id In this case you get all the married men with their wifes as well as all unmarried men. Change to right join you get all the couples and all the unmarried women. That being set, you never need right joins. You can simply switch the tables in your statement. That is good for readability.
1st Oct 2017, 4:45 AM
1of3
1of3 - avatar
0
Now I know, noted this.Thanks!
1st Oct 2017, 11:14 AM
Aurelio Pantaleon II
Aurelio Pantaleon II - avatar