[Data Science] Transact-SQL : Introduction to Joins

Online Learning 2020. 12. 11. 15:00

JOIN Concepts

  • Combine rows from multiple tables by specifying matching criteria
    • Usually based on primary key – foreign key relationships
  • It helps to think of the tables as sets in a Venn diagram

JOIN Syntax

FROM 절에서 JOIN 

SELECT ...
FROM   Table1 JOIN Table2
       ON <on_predicate>;

 

FROM 절에서 콤마(,)를 사용해 JOIN

Cartesian products(모든 경우의 수를 구하는 방법)이 이루어지므로 일반적으로 이 방법은 추천하지 않는다.

SELECT ...
FROM   Table1, Table2
WHERE  <where_predicate>;

 

: