Info
Open the page on your phone

Types of JOIN and their differences

In SQL, there are three types of JOIN:

  • INNER JOIN returns only the rows that are present in both tables involved in the join.
  • OUTER JOIN returns all rows from one table, even if they do not have corresponding rows in the other table.
  • CROSS JOIN returns all possible combinations of rows from two tables.
  • Differences between the types of JOIN

    INNER JOIN

  • Returns only the rows that are present in both tables involved in the join.
  • Used when you need to get only the data that is common to two tables.
  • OUTER JOIN

  • Returns all rows from one table, even if they do not have corresponding rows in the other table.
  • Used when you need to get all data from one table, regardless of whether they are in the other table.
  • CROSS JOIN

  • Returns all possible combinations of rows from two tables.
  • Used when you need to get all possible combinations of data from two tables.