SELECT COUNT(*) FROM TABLE1 INNER JOIN TABLE2
ON TABLE1.ID <> TABLE2.ID
The number of rows in TABLE1 times the number of rows in TABLE2 minus the number of rows that the two tables have in common
Correct:
The number of rows in TABLE1 times the number of rows in TABLE2 minus the number of rows that the two tables have in common
Explanation:
This is a very tricky question - and, yet, it illustrates a very common conceptual mistake about the way joins work. Despite the fact that one might be tempted to think that this query extracts the rows that the two tables do not have in common, the database takes it to mean “extract all the rows in which the IDs are different.” There is a substantial difference at work here: the DBMS will simply take every row on the left and add to the result set every row on the right that doesn’t have a matching ID. Therefore, the query will extract every row from TABLE1 times every row from TABLE2, minus the rows that the two have in common, thus making Answer C correct.