You are on page 1of 2

Notes on third class ‘SQL for Data Science’ DQACADEMY

1. JOIN
1.1. Inner Join  when 2 table have a column which are related to each other. Then, we can
join with conditional function
Ex:

Table A and Table B,

SELECT * FROM Table A, Table B;


WHERE column A1 = column B1

Explanation: column A1 is part of Table A and column B1 is part of Table B. column A1


and B1 should have similarity than we call them as key column. Than when we use
conditional (WHERE =) the new table will show just the same value of A1 and B1

1.2. Cross Join


When we join two table without conditional function, we called cross join. If the column
A1 contains 6 datum/variables/row and B1 contain 7 data than the new table will
contain 6 x 7 rows.

2. Detailed information about JOIN (inner join, left join, right join, etc)
2.1. Inner Join

Actually, in some points, we ‘ll get same result compare to inner join using conditional,
but using this type of inner join will give you more capability to arrange the output of the
table that you want.
A. Choosing some columns to be shown.
We can choose which column we want to show. If we use the coding above all the
columns from table 1 and table 2 will be shown and the key columns are shown
twice. This is the method how to implement it.

3. UNION
If JOIN is a method to combine two tables or more horizontally, then UNION is a method to
combine it vertically.
UNION requirement:
a. The tables should have the same number of columns
b. Those columns should have the same type of data
c. Those columns should have the same sequence

You might also like