W3. SQL Right Join Flashcards

1
Q

Q: What does the SQL RIGHT JOIN keyword do?

A

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

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

Q: Write the syntax for a RIGHT JOIN.

A

SELECT column_name(s)
FROM table1
RIGHT 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 RIGHT JOIN in some databases?

A

A: RIGHT OUTER JOIN

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

Q: Write a query to return all employees and any orders they may have placed, ordered by OrderID.

A

SELECT Orders.OrderID, Employees.LastName, Employees.FirstName
FROM Orders
RIGHT JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID
ORDER BY Orders.OrderID;

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

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

A

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

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