0% found this document useful (0 votes)
39 views1 page

Description Diagram Syntax: X Z X Z

An inner join matches rows between two tables where there is a match in the common column. A left join returns all rows from the left table and matching rows from the right table. A cross join combines all rows from one table with all rows from another table. The union command stacks one dataset on top of another.

Uploaded by

Joseph Chris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

Description Diagram Syntax: X Z X Z

An inner join matches rows between two tables where there is a match in the common column. A left join returns all rows from the left table and matching rows from the right table. A cross join combines all rows from one table with all rows from another table. The union command stacks one dataset on top of another.

Uploaded by

Joseph Chris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Learn SQL from Scratch

Description Diagram Syntax

An inner join matches each row of table1 table2 SELECT *


one table with rows of a second
col A col B col B col C FROM table1
table based on a common column.
The resulting table will only contain JOIN table2
a x = x d
rows where there is a match in both ON table1.colB = table2.colB;
b y = w e
the left and right tables.
c z = z f

INNER JOIN
col A col B col C
a x d
c z f

A left join matches each row of one table1 table2 SELECT *


table with rows of a second table
col A col B col B col C FROM table1
based on a common column. The
resulting table will only contain all LEFT JOIN table2
a x = x d
data from the first (left) table, and ON table1.colB = table2.colB;
b y = w e
additional data from the second
(right) table for where there was no c z = z f
matching information from the
right table.

LEFT JOIN
col A col B col C
a x d
b yz
c z f

A cross join combines all rows table1 table2 SELECT *


of one table with all rows of FROM table1
another table. col A col B col C col D
CROSS JOIN table2;
a c e h
b d f i
g j

CROSS JOIN
col A col B col C col D
a c e h
b d e h
a c f i
b d f i
a c g j
b d g j

The command union allows table1 table2 SELECT *


us to stack one dataset on top FROM table1
col A col B col C col D
of the other.
UNION
a c e h
SELECT *
b d f i
FROM table2;
g j

UNION
col A col B
a c
b d
e h
f i
g j

You might also like