Which operator returns rows from the first query not present in the second query?

Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

Which operator returns rows from the first query not present in the second query?

Explanation:
This tests the idea of set difference. The operator that returns rows from the first query that aren’t present in the second is the set difference operator. It shows all rows from the first result, but removes any rows that also appear in the second result. For example, if the first query yields 1, 2, 3 and the second yields 2, 4, the result is 1 and 3. In SQL you’d write it as a subtraction between two result sets. By default, duplicates are removed, though some databases offer an EXCEPT ALL variant to keep duplicates. Why this is the right fit: UNION merges results from both queries; INTERSECT returns only rows that appear in both; JOIN combines rows from two sources based on a relationship. The exact behavior described—keeping only rows unique to the first set—matches the idea of subtracting the second result from the first.

This tests the idea of set difference. The operator that returns rows from the first query that aren’t present in the second is the set difference operator. It shows all rows from the first result, but removes any rows that also appear in the second result. For example, if the first query yields 1, 2, 3 and the second yields 2, 4, the result is 1 and 3. In SQL you’d write it as a subtraction between two result sets. By default, duplicates are removed, though some databases offer an EXCEPT ALL variant to keep duplicates.

Why this is the right fit: UNION merges results from both queries; INTERSECT returns only rows that appear in both; JOIN combines rows from two sources based on a relationship. The exact behavior described—keeping only rows unique to the first set—matches the idea of subtracting the second result from the first.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy