Search code examples
mysqldatabasejoinleft-joinright-join

Left and Right Join Giving the same output


Im trying to do Left and Right join but its not working properly . Lemme show you..

Student Table

Student Table

Address Table

Address Table

What's i'm doing?

  1. SELECT * FROM student JOIN address ON student.tid = address.stud_tid

Output:

Simple Join

  1. SELECT * FROM student LEFT JOIN address ON student.tid = address.stud_tid

Output:

Left Join

  1. SELECT * FROM student RIGHT JOIN address ON student.tid = address.stud_tid

Output:

Right Join

May i know why im getting the same out put in every case ?

it should be like rows output like this one

Output Join


Solution

  • That's because your data are complete. Every student has an address. If you remove one or more addresses, results will be different.