DEV Community

Rose1845
Rose1845

Posted on

SQL Joins and Window Functions

Why SQL join?

  1. Recombine Data - combine the tables in one big result > Big picture
  2. Data enrichment - when you want to get extra data
  3. Check existence of other data in order to check that you need the help of another table > filtering

When you want to combine two tables, let's say table A and table B, that is through

  1. Columns - in this, we combine the columns from the tables using the SQL JOINs We have 4 common types of joins
  • LEFT JOIN
  • RIGHT JOIN
  • INNER JOIN
  • FULL OUTER JOIN
  1. Rows - when you combine 2 or more tables through rows, we use the SET Operators like UNION, UNION ALL, INTERSECT, EXCEPT. And here, all the number of columns and data types must match

Today, we are going to talk about 4 common types of JOIN(s)

LEFT JOIN - returns data from the left table that hs match on the right table, even if there is no match
Right join - return data from the right table that has match on the left table
INNER JOIN - returns data matching from the 2 tables
FULL OUTER JOIN - return data from the 2 tables filled with nulls from both tables

Top comments (0)