W3. SQL Joins Flashcards

1
Q

Q: What is the purpose of the SQL JOIN clause?

A

A: It combines rows from two or more tables based on a related column between them.

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

Q: Write a query to perform an INNER JOIN on “Orders” and “Customers” using CustomerID.

A

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;

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

Q: What does an INNER JOIN return?

A

A: Records that have matching values in both tables.

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

Q: What are the four types of SQL joins?

A

(INNER) JOIN: Returns matching records from both tables.

LEFT (OUTER) JOIN: Returns all records from the left table and matched records from the right.

RIGHT (OUTER) JOIN: Returns all records from the right table and matched records from the left.

FULL (OUTER) JOIN: Returns all records when there is a match in either table.

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

Q: What does a LEFT JOIN do?

A

A: Returns all records from the left table and matched records from the right table.

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

Q: What does a RIGHT JOIN do?

A

A: Returns all records from the right table and matched records from the left table.

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

Q: What does a FULL JOIN do?

A

A: Returns all records when there is a match in either the left or right table.

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

Q: In which SQL JOIN would you get only records that exist in both tables?

A

A: INNER JOIN

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

Q: Describe the relationship between “Orders” and “Customers” in the provided example.

A

A: The CustomerID column in “Orders” refers to CustomerID in “Customers,” linking records between the two tables.

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