Joining Data In SQL takeaways
https://gatlabs.com/blogpost/sql-definition/

Joining Data In SQL takeaways

I just finished Joining Data In SQL on DataCamp.

Here are my takeaways.


JOINS (Combines columns)

1. JOIN

  • INNER JOIN - joins matching records where key fields is in both tables
  • SELF JOIN - join table with itself

2. OUTER JOIN

  • LEFT JOIN - keeps all records on left, matching records on the right
  • RIGHT JOIN - keeps all records on right, matching records on the left
  • FULL JOIN - combines left and right join result (keeps all records from both tables)
  • CROSS JOIN - all possible combinations (no ON or USING clause)

3. FILTER JOIN

  • SEMI JOIN - filter (with WHERE clause) first table for observations that match second
  • ANTI JOIN - opposite of semi join (diagnosing problems of joins with fewer results that expected)

Self join, semi join, and anti don't have built-in SQL syntax.


SET THEORY (combines rows)

  • UNION - stacks records and removes duplicates
  • UNION ALL - stacks everything
  • INTERSECT - return only records appearing on both tables
  • EXCEPT - records in one that aren't in another


Types of Subqueries

  • inside WHERE (most frequent)
  • inside SELECT (must have alias for temporary table)
  • inside FROM (must have alias for temporary table)
  • inside ON (rare)


Example of subquery from the class

  • In this subquery, we're looking at the maximum inflation rate for each continent in the year 2015.
  • the inner subquery in the FROM clause runs first, then the one in the IN clause, then the main query.
No alt text provided for this image


Next course: Intermediate SQL


Resources


Here's an awesome visual explanation on SQL joins


View my certificate

Thank you!

要查看或添加评论,请登录

Benedict Neo的更多文章

  • Intermediate SQL takeaways

    Intermediate SQL takeaways

    I just finished the Intermediate SQL course on DataCamp, here are my takeaways. Click here if you want the full version…

  • Introduction to SQL takeaways

    Introduction to SQL takeaways

    I just finished the Introduction to SQL course on DataCamp. Here are my takeaways.

社区洞察

其他会员也浏览了