SQL Inner Join

6.What type of join returns only common records from two tables?
  • A. RIGHT JOIN
  • B. INNER JOIN
  • C. FULL JOIN
  • D. LEFT JOIN

INNER JOIN

INNER JOIN

7.What is the output?
Table A Table B id | name id | city 1 | John 1 | Delhi 2 | Mike 3 | Mumbai SELECT A.name, B.city FROM A INNER JOIN B ON A.id = B.id;
  • A. John – Delhi
  • B. Mike – Mumbai
  • C. 2 rows
  • D. No rows

John – Delhi

John – Delhi

8.If A.id has values 1, 2, 3 and B.id has 2, 3, 4 — how many rows in output?
SELECT * FROM A INNER JOIN B ON A.id = B.id;
  • A. 1
  • B. 2
  • C. 3
  • D. 4

2

2

9.If there are no matching customer IDs in customers, what will COUNT return?
SELECT COUNT(*) FROM orders INNER JOIN customers ON orders.customer_id = customers.id;
  • A. All orders
  • B. 0
  • C. NULL
  • D. Error

0

0

10.If B has NULL values in id, what happens?
SELECT A.name, B.city FROM A INNER JOIN B ON A.city_id = B.id;
  • A. JOIN includes those rows
  • B. JOIN skips them
  • C. NULL shown in results
  • D. Error

JOIN skips them

JOIN skips them