Lecture 4 Flashcards

1
Q

What are SQL joins? and what are the 4 we must know?

A

A join clause is used to combine rows from two or more tables, based on a related column between them.
Inner, Outer, Left and Right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Simple/INNER JOIN

A

Only the things that match on the left and the right.

SELECT *
FROM table1
INNER JOIN Table2
ON table1.KEY = Table2.KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Left JOIN

A

Everything on the left, plus anything on the right that matches.

SELECT *
FROM table1
LEFT JOIN Table2
ON table1.KEY = Table2.KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Right JOIN

A

Everything on the right, plus anything on the left that matches.

SELECT *
FROM table1
RIGHT JOIN Table2
ON table1.KEY = Table2.KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Outer JOIN

A

Everything on the right, plus everything on the left.

SELECT *
FROM table1
OUTER JOIN Table2
ON table1.KEY = Table2.KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

AS

A

AS is an aliase to tables or columns to make queries shorter or more readable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

USING

A

We can use USING if the names of columns in both join tables are equal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly