SQL Right Join
6.RIGHT JOIN can also be written as:
-
A. LEFT JOIN with table order reversed
-
B. INNER JOIN
-
C. FULL JOIN
-
D. JOIN
LEFT JOIN with table order reversed
LEFT JOIN with table order reversed
7.What does this return? - If B has ids 1, 2, 3 and A has only id 1:
SELECT A.id, B.value
FROM A RIGHT JOIN B ON A.id = B.id;
-
A. Only 1 row
-
B. 3 rows, A.id is NULL for id 2 & 3
-
C. 0 rows
-
D. Error
3 rows, A.id is NULL for id 2 & 3
3 rows, A.id is NULL for id 2 & 3
8.RIGHT JOIN ensures:
-
A. Every row in left table appears
-
B. Every row in right table appears
-
C. No duplicates
-
D. No NULLs
Every row in right table appears
Every row in right table appears
9.What is the result of: If dept has 3 rows, 1 matching in emp:
SELECT *
FROM emp RIGHT JOIN dept ON emp.dept_id = dept.id;
-
A. 3 rows with NULLs for unmatched
-
B. Only matched row
-
C. Error
-
D. 1 row
3 rows with NULLs for unmatched
3 rows with NULLs for unmatched
10.Why use RIGHT JOIN instead of LEFT JOIN?
-
A. It’s faster
-
B. When you want all rows from right side
-
C. It sorts data
-
D. It avoids NULLs
When you want all rows from right side
When you want all rows from right side