Finding Rows in Table A that have no Corresponding Rows in Table B

Given two tables, "A" and "B", write a SQL query to find all the rows from table "A" that have no corresponding rows in table "B".

Problem

Given two tables, "A" and "B", write a SQL query to find all the rows from table "A" that have no corresponding rows in table "B".
Input:
Table A:
id | data
---|------
1  | abc
2  | def
3  | ghi
Table B:
id | data
---|------
2  | def
3  | ghi
4  | jkl
Output:
Table A:
id | data
---|------
1  | abc

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT * FROM A
LEFT JOIN B ON A.id = B.id
WHERE B.id IS NULL;

/*

The above solution is optimal because it uses a LEFT JOIN, which will return all rows from table A, even if there is no corresponding row in table B.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of SQL. The approach is sound and the solution is complete.

Evaluated at: 2022-11-19 00:16:48