INNER JOINS

When we decide that one table won’t be enough for getting our desired output then we try to attach one more table to the existing table is known as JOINS. Now Inner Joins in other words is doing the same thing as the definition of joins goes but with an additional advantage which is based on a particular key column from table 1 and similar key column in table 2 then if the condition exist then it clubs that table and solely ignores rows that does not satisfy the condition

Now practically [using PGAdmin]

Blog

LEFT JOINS & RIGHT JOINS

As we defined joins this is also similar but with Left Joins it clubs the 1st table and 2nd Table based on the condition and also rows that does not satisfy the condition in the 2nd Table

Similarly it we can say for Right Joins but in vice versa manner

 

Real Time

person_disability table has 25 Rows and a column with personid
and person_employment has 19558 rows and also column with personid

Now lets see when we say

LEFT

It returned 12663 after adding few filters why?
Because Based on the 1st Table(Left Table) the condition will execute.

I.e. the table person_employment total rows will execute
and only does rows in the person_disability table that satisfy the condition will show and also NULL rows will also show (because those rows does not satisfy the condition).

 

Now if we Right Join the Same table let’s see what happens?

RIGHT

Now it returned 25 rows after adding few filters why?

Because based on the 2nd Table (Right Table) the condition will execute.

I.e. the person_disability table total rows will execute
and only does rows in the person_employment table that satisfy the condition will show and also NULL rows will also show (because those rows does not satisfy the condition).

We can also attain a RIGHT JOIN Using a Left join by swapping the names of the table
example

LEFT1

In My next Blog we will discuss on CROSS JOIN

Leave a Reply