Joins

SQL JOIN is used to combine two or more tables in a database based on a related column between them. The JOIN operation returns a result set containing all the columns from the joined tables.

JOIN operators are used to combine data from multiple tables

  • Inner joins return only rows from the tables that match on a common value

  • Outer joins return the same matched rows as the inner join, plus unmatched rows from one table or the other

There are different types of SQL JOINs, including:

  1. INNER JOIN: returns only the rows that have matching values in both tables being joined.

  2. LEFT JOIN: returns all the rows from the left table and the matched rows from the right table. If there are no matching rows in the right table, the result will contain NULL values for the right table's columns.

  3. RIGHT JOIN: returns all the rows from the right table and the matched rows from the left table. If there are no matching rows in the left table, the result will contain NULL values for the left table's columns.

  4. FULL OUTER JOIN: returns all the rows from both tables, and NULL values will be added for non-matching rows.

Â