SQL Right Join

1.What is returned by a RIGHT JOIN?
  • A. All rows from left table
  • B. All rows from right table + matched from left
  • C. Only matched rows
  • D. Only unmatched rows

All rows from right table + matched from left

All rows from right table + matched from left

2.Which is the correct SQL syntax for RIGHT JOIN?
SELECT * FROM A RIGHT JOIN B ON A.id = B.id;
  • A. Correct syntax
  • B. Invalid – use WHERE instead
  • C. Invalid – use LEFT JOIN
  • D. RIGHT JOIN does not exist in SQL

Correct syntax

Correct syntax

3.What will this return?
Table A Table B id | name id | dept 1 | Raj 1 | HR 2 | Simran 2 | IT 3 | Sales SELECT B.dept, A.name FROM A RIGHT JOIN B ON A.id = B.id;
  • A. All 2 matched only
  • B. 3 rows, name is NULL for dept = Sales
  • C. Only dept = HR, IT
  • D. Error

3 rows, name is NULL for dept = Sales

3 rows, name is NULL for dept = Sales

4.If RIGHT JOIN returns NULLs in the left table columns, what does it mean?
  • A. Error occurred
  • B. Right table didn’t match
  • C. Left table has no matching value

Left table has no matching value

Left table has no matching value

5.If table A has 2 rows and B has 5 rows (no matches), how many rows in A RIGHT JOIN B?
  • A. 2
  • B. 5
  • C. 7
  • D. 0

5

5