Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Discuss join and types with suitable example. Define join. Explain different types of join.

Inner Join:

  • This join returns only the rows where there is a match between the columns in both tables.
  • Imagine you have a list of employees and a list of their salaries. If you do an inner join, you’ll only get the rows where there’s a matching employee in both lists.
  • For example, if you have:
    • Employee: (Emp_Name, City)
    • Employee_Salary: (Emp_Name, Department, Salary)
Employee.Emp_NameEmployee.CityEmployee_Salary.Salary
HariPune10000
OmMumbai7000
JaiSolapur5000

Outer Join:

  • Outer joins include rows from one table even if there are no matches in the other table.
  • There are two types of outer joins: left outer join and right outer join.

a. Left Outer Join:

  • This includes all rows from the left table (the first table mentioned) and matching rows from the right table.
  • If there’s no match in the right table, it fills in with NULL values.
  • For example, if you run:
Employee.Emp_NameEmployee.CityEmployee_Salary.Salary
HariPune10000
OmMumbai7000
JaiSolapur5000
Surajnullnull

b. Right Outer Join:

  • This is similar to the left outer join but includes all rows from the right table (the second table mentioned).
  • If there’s no match in the left table, it fills in with NULL values.
  • For example, if you run:
Employee.Emp_NameEmployee.CityEmployee_Salary.Salary
HariPune10000
OmMumbai7000
JaiSolapur5000
Billunull8000

Leave a Comment