Question

    Which query retrieves all records from TableA that have

    no corresponding records in TableB?
    A SELECT * FROM TableA INNER JOIN TableB ON TableA.id = TableB.id; Correct Answer Incorrect Answer
    B SELECT * FROM TableA LEFT JOIN TableB ON TableA.id = TableB.id WHERE TableB.id IS NULL; Correct Answer Incorrect Answer
    C SELECT * FROM TableA RIGHT JOIN TableB ON TableA.id = TableB.id WHERE TableA.id IS NULL; Correct Answer Incorrect Answer
    D SELECT * FROM TableA FULL OUTER JOIN TableB ON TableA.id = TableB.id; Correct Answer Incorrect Answer
    E SELECT * FROM TableA WHERE id NOT IN (SELECT id FROM TableB); Correct Answer Incorrect Answer

    Solution

    A LEFT JOIN retrieves all records from TableA and the matching records from TableB. If no match exists, the TableB fields are NULL. Filtering on TableB.id IS NULL ensures only those records from TableA with no match in TableB are selected. Why Other Options Are Incorrect: 1. INNER JOIN: Retrieves only matching records, not unmatched ones. 2. RIGHT JOIN: Retrieves unmatched records from TableB, not TableA. 3. FULL OUTER JOIN: Includes all unmatched records but does not isolate TableA exclusively. 4. NOT IN: Functional but less efficient than LEFT JOIN.

    Practice Next