W3. SQL Left Join Flashcards

1
Q

Q: What does the SQL LEFT JOIN keyword do?

A

A: It returns all records from the left table and the matching records from the right table. If there’s no match, it returns 0 records from the right side.

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

Q: Write the syntax for a LEFT JOIN.

A

SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;

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

Q: What is another name for LEFT JOIN in some databases?

A

A: LEFT OUTER JOIN

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

Q: Write a query to select all customers and any orders they may have, sorted by CustomerName.

A

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID
ORDER BY Customers.CustomerName;

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

Q: What happens in a LEFT JOIN if there is no matching record in the right table?

A

A: The result will include all records from the left table, and 0 (NULL) for columns from the right table with no match.

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